Skip to content

Instantly share code, notes, and snippets.

@utgwkk
Created March 18, 2016 22:25
Show Gist options
  • Save utgwkk/cd784cee1396a2445574 to your computer and use it in GitHub Desktop.
Save utgwkk/cd784cee1396a2445574 to your computer and use it in GitHub Desktop.
「ズン」「ドコ」のいずれかをランダムに返し、「ズンズンズンズンドコ」の順番に yield されたら「キ・ヨ・シ!」を yield するジェネレータ
# 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