Skip to content

Instantly share code, notes, and snippets.

@kokumura
Last active May 7, 2017 00:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kokumura/bc0f122fcd217c102206db0101884e60 to your computer and use it in GitHub Desktop.
Save kokumura/bc0f122fcd217c102206db0101884e60 to your computer and use it in GitHub Desktop.
katan-haibun.py
import random
import sys
C = ['ヒツジ', '麦', 'レンガ', '木', '石']
def katan(n):
import collections
c = collections.defaultdict(lambda: 0)
for i in range(n):
c[random.choice(C)] += 1
return c
for k, v in katan(int(sys.argv[1])).items():
print(f'{k} => {v}')
@kokumura
Copy link
Author

kokumura commented May 5, 2017

$ python katan-haibun.py 10
麦 => 3
レンガ => 2
木 => 4
石 => 1

requires Python >= 3.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment