Created
October 22, 2017 08:20
-
-
Save emergent/b57bd74d7addaee0436863d84baab17b to your computer and use it in GitHub Desktop.
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
import random | |
ZUN = "zun" | |
DOKO = "doko" | |
MAXLEN = 4 | |
def match(arr): | |
print(arr) | |
if (len(arr) >= MAXLEN | |
and arr[0] == ZUN | |
and arr[1] == ZUN | |
and arr[2] == ZUN | |
and arr[3] == 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