Created
March 1, 2021 12:34
-
-
Save koba-e964/99313469ac0803936d002f0ec879ba58 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python3 | |
import random | |
i_vowel = list('きしちにひみりぴじぎぢ') | |
tsu = list('っッ') | |
def is_valid(s): | |
l = len(s) | |
if s[l - 1] in tsu or s[0] in tsu: | |
return False | |
for i in range(0, l): | |
if s[i] == 'ゃ' or s[i] == 'ゅ' or s[i] == 'ょ': | |
if i == 0 or s[i - 1] not in i_vowel: | |
return False | |
if s[i] == 'ー': | |
if i == 0 or s[i - 1] == 'ー': | |
return False | |
return True | |
s = list(input()) | |
c = 0 | |
while c < 20: | |
ans = random.sample(s, len(s)) | |
if not is_valid(ans): | |
continue | |
print(''.join(ans)) | |
c += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment