Created
April 23, 2018 19:16
-
-
Save sofyan48/12f1d3b32743943a868a34a4c146ca4c to your computer and use it in GitHub Desktop.
palindrom_interview
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def checkIsPalindrom(kata_str): | |
| calback = False | |
| pola = [ | |
| 'a','i','u','e','o', | |
| 'ka','ki','ku','ke','ko', | |
| 'sa','shi','su','se','so', | |
| 'ta','chi','tsu','te','to', | |
| 'na','ni','nu','ne','no', | |
| 'ha','hi','fu','he','ho', | |
| 'ma','mi','mu','me','mo', | |
| 'ya','yu','yo', | |
| 'ra','ri','ru','re','ro', | |
| 'wa','wi','we','wo' | |
| ] | |
| my_str = kata_str.casefold() | |
| kata_split = my_str.split(" ") | |
| kata=[] | |
| for i in kata_split: | |
| polaKata=[] | |
| for p,v in enumerate(pola): | |
| if v in i: | |
| polaKata.append(str(v)) | |
| kata.append(polaKata) | |
| first = kata[0] | |
| for x in kata[1:]: | |
| if first == x : | |
| calback = True | |
| else: | |
| calback = False | |
| return calback | |
| a = checkIsPalindrom("kurumi to hoto miruku") | |
| b = checkIsPalindrom("kotori no koto suki") | |
| print(a) | |
| print(b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment