Skip to content

Instantly share code, notes, and snippets.

@koba-e964
Created March 1, 2021 12:34
Show Gist options
  • Save koba-e964/99313469ac0803936d002f0ec879ba58 to your computer and use it in GitHub Desktop.
Save koba-e964/99313469ac0803936d002f0ec879ba58 to your computer and use it in GitHub Desktop.
#!/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