LoginSignup
0
2

More than 3 years have passed since last update.

「世界で闘うプログラミング力を鍛える本」Pythonコード解答例 - 1.2 同じ文字の数を数える

Last updated at Posted at 2020-01-30

「世界で闘うプログラミング力を鍛える本」Pythonコード解答例 - 1.2 同じ文字の数を数える

目次

CHAP1. 配列と文字列

  1. 重複のない文字列
  2. 同じ文字の数を数える
  3. URLify
  4. 回文の順列
  5. 一発変換
  6. 文字列圧縮
  7. 行列の回転
  8. "0"の行列
  9. 文字列の回転

Pythonコード解答例

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))
0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2