"A book to train programming skills to fight in the world" Python code answer example --1.2 Count the number of the same characters

"A book to train programming skills to fight in the world" Python code answer example --1.2 Count the number of the same characters

table of contents

CHAP1. Arrays and strings

  1. Unique string
  2. Count the number of the same characters
  3. URLify
  4. Palindrome permutation
  5. One-shot conversion
  6. String compression
  7. Rotate matrix
  8. Matrix of "0"
  9. Rotate string

Python code answer example

import numpy as np

def stringSort(str):
    return "".join(sorted(str))

def permutation(str_1,str_2):

    if len(str_1) != len(str_2):
        return False

    return stringSort(str_1) == stringSort(str_2)

input_str_1 = "no"
input_str_2 = "on"

print(permutation(input_str_1,input_str_2))

input_str_3 = "yes"
input_str_4 = "no"

print(permutation(input_str_3,input_str_4))

Recommended Posts

"A book to train programming skills to fight in the world" Python code answer example --1.2 Count the number of the same characters
"A book to train programming skills to fight in the world" Python code answer example --1.9 Rotation of strings
"A book to train programming skills to fight in the world" Python code answer example --1.8 "0" matrix
"Book to train programming skills to fight in the world" Python code answer example --1.4 Permutation of sentences
"Book to train programming skills to fight in the world" Python code answer example --1.3 URLify
"Book to train programming skills to fight in the world" Python code answer example --2.6 palindrome
"Book to train programming skills to fight in the world" Python code answer example --2.4 Splitting the list
"Book to train programming skills to fight in the world" Python code answer example --2.7 intersecting nodes
"A book to train programming skills to fight in the world" Python code answer example --2.2 Returns the Kth from the back
"A book to train programming skills to fight in the world" Python code Solution example --1.6 String compression
"A book to train programming skills to fight in the world" Python code solution example --1.5 One-shot conversion
"A book to train programming skills to fight in the world" Python code Solution example --1.7 Matrix rotation
"A book to train programming skills to fight in the world" Python code Solution example --2.8 Loop detection
"A book to train programming skills to fight in the world" Python code Solution example --2.5 The sum of two numbers shown in the list
"Book to train programming skills to fight in the world" Python code solution example --- Removed elements between 2.3
"Book to train programming skills to fight in the world" Python code Solution example --2.1 Remove duplicate elements
How to identify the element with the smallest number of characters in a Python list?
Programming to fight in the world ~ 5-5,5-6
Programming to fight in the world 5-3
Programming to fight in the world ~ 5-2
[Python] Programming to find the number of a in a character string that repeats a specified number of times.
How to quickly count the frequency of appearance of characters from a character string in Python?
Count the number of Thai and Arabic characters well in Python
An example of the answer to the reference question of the study session. In python.
Count the number of times two values appear in a Python 3 iterator type element at the same time
4 methods to count the number of occurrences of integers in a certain interval (including imos method) [Python implementation]
[Kenchon book to Python] "Train your problem-solving skills! Algorithms and data structures" I tried to rewrite the posted code in Python! -table of contents-
How to count the number of elements in Django and output to a template
How to get a list of files in the same directory with python
How to count the number of occurrences of each element in the list in Python with weight
Count the number of characters in the text on the clipboard on mac
Get the number of specific elements in a python list
[Homology] Count the number of holes in data with Python
How to determine the existence of a selenium element in Python
[Python] PCA scratch in the example of "Introduction to multivariate analysis"
How to check the memory size of a variable in Python
Programming to fight in the world-Chapter 4
I wrote the code to write the code of Brainf * ck in python
How to check the memory size of a dictionary in Python
Get the number of readers of a treatise on Mendeley in Python
How to run the practice code of the book "Creating a profitable AI with Python" on Google Colaboratory
[Python] A program that calculates the number of socks to be paired
[Python] How to put any number of standard inputs in a list
Check the in-memory bytes of a floating point number float in Python
What kind of book is the best-selling "Python Crash Course" in the world?
Python code to determine the monthly signal of a relative strength investment
I made a program to check the size of a file in Python
Project Euler # 17 "Number of Characters" in Python
Count the number of characters with echo
[Kenchon book to Python]-Chapter 3- "Train your problem-solving skills! Algorithms and data structures" I rewrote the posted code to Python!
Part 1 I wrote an example of the answer to the reference problem of how to write offline in real time in Python
[Kenchon book to Python]-Chapter 2- "Train your problem-solving skills! Algorithms and data structures" I rewrote the posted code to Python!
[Kenchon book to Python]-Chapter 4-"Train your problem-solving skills! Algorithms and data structures" I rewrote the posted code to Python!
Various ways to read the last line of a csv file in Python
How to pass the execution result of a shell command in a list in Python
Set the number of elements in a NumPy one-dimensional array to a power of 2 (0 padded)
Divides the character string by the specified number of characters. In Ruby and Python.
Visualize the timeline of the number of issues on GitHub assigned to you in Python
I searched for the skills needed to become a web engineer in Python
Output the number of CPU cores in Python
Get the caller of a function in Python