Last active
October 22, 2017 10:32
-
-
Save emergent/3e7723cb7447a9c4f12bcfcf38303540 to your computer and use it in GitHub Desktop.
This file contains 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
import random | |
ZUN = "zun" | |
DOKO = "doko" | |
MAXLEN = 5 | |
def match(arr): | |
print(arr) | |
if (len(arr) >= MAXLEN | |
and arr[0] == ZUN | |
and arr[1] == ZUN | |
and arr[2] == ZUN | |
and arr[3] == ZUN | |
and arr[4] == DOKO): | |
return True | |
return False | |
def zundoko(): | |
words = [] | |
counter = 0 | |
ZUNDOKO = [ZUN,DOKO] | |
KIYOSHI = "kiyoshi!" | |
while (not match(words)): | |
counter += 1 | |
words.append(ZUNDOKO[random.randint(0,1)]) | |
if len(words) > MAXLEN: | |
words.pop(0) | |
print(KIYOSHI) | |
print(counter) | |
if __name__ == '__main__': | |
zundoko() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment