Created
March 18, 2016 22:25
-
-
Save utgwkk/cd784cee1396a2445574 to your computer and use it in GitHub Desktop.
「ズン」「ドコ」のいずれかをランダムに返し、「ズンズンズンズンドコ」の順番に yield されたら「キ・ヨ・シ!」を yield するジェネレータ
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
| # coding: utf-8 | |
| import random | |
| def zundoko(): | |
| s = 'ズン', 'ドコ' | |
| q = [] | |
| while True: | |
| z = random.choice(s) | |
| yield z | |
| q.insert(0, z) | |
| if len(q) > 5: | |
| q.pop(5) | |
| if ''.join(q) == 'ドコズンズンズンズン': | |
| break | |
| yield 'キ・ヨ・シ!' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment