Skip to content

Instantly share code, notes, and snippets.

@Bakudankun
Created November 6, 2024 16:16
Show Gist options
  • Save Bakudankun/49d29f55e1a8b0d0a94ba745add570db to your computer and use it in GitHub Desktop.
Save Bakudankun/49d29f55e1a8b0d0a94ba745add570db to your computer and use it in GitHub Desktop.
import random
print('ぬん')
letters = {
'し': {'population': ['か', 'た'], 'weights': [0.5, 0.5]},
'か': {'population': ['の'], 'weights': [1]},
'の': {'population': ['こ'], 'weights': [1]},
'こ': {'population': ['の', 'こ', 'し'], 'weights': [0.5, 0.25, 0.25]},
'た': {'population': ['ん'], 'weights': [1]},
'ん': {'population': ['た', ' '], 'weights': [0.5, 0.5]},
' ': {'population': [' ', 'し'], 'weights': [0.5, 0.5]},
}
recent = []
print('し', end='')
recent.append('し')
random.seed()
while 1:
choices = letters[recent[-1]]
next = random.choices(choices['population'], choices['weights'])[0]
print(next, end='')
recent.append(next)
if len(recent) > 15:
del recent[0]
if ''.join(recent) == 'しかのこのこのここしたんたん' or ''.join(recent) == ' しかのこのこのここしたんたん':
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment