Here Let's get on for the time being.
zundoko.py
# coding:utf-8
from random import choice
ZUNDOKO_MESSAGE = 'Zunzunzundoko'
KIYOSHI = 'Ki yo shi!'
def zundoko():
check_list = []
while ''.join(check_list[-5:]) != ZUNDOKO_MESSAGE:
check_list.append(choice(['Dung', 'Doco']))
print check_list[-1]
print KIYOSHI
if __name__ == '__main__':
zundoko()
Run
$ python zundoko.py
Dung
Doco
Dung
Doco
Doco
Dung
Doco
Doco
Dung
Doco
Doco
Dung
Doco
Doco
Dung
Doco
Doco
Dung
Dung
Dung
Dung
Doco
Ki yo shi!
Umu
While many people aim for a small number of bytes, they do wasteful things. Well, there are various ramblings.
ZundokoKiyoshi.py
# coding:utf-8
from random import choice
class ZundokoKiyoshi:
CORRECT_MESSAGE = 'Zunzunzundoko'
RESULT_MESSAGE = 'Ki yo shi!'
_message_list = ['Dung', 'Doco']
_result = []
def say_rand(self):
'''
Randomly return a message
'''
return choice(self._message_list)
def append(self, message):
'''
Add a message to the list
'''
self._result.append(message)
def empty(self):
'''
Empty the list
'''
self._result = []
def is_correct(self):
'''
Check the messages in the list and return if the message is correct
'''
return ''.join(self._result[-5:]) == self.CORRECT_MESSAGE
def print_result(self):
'''
Returns a result message
'''
print ''.join(self._result) + self.RESULT_MESSAGE
def check(self):
'''
Run Zundokokiyoshi
'''
while (self.is_correct() is False):
self.append(self.say_rand())
self.print_result()
self.empty()
return True
How to use
execZundokoKiyoshi.py
# coding:utf-8
from ZundokoKiyoshi import ZundokoKiyoshi
if __name__ == '__main__':
zundoko = ZundokoKiyoshi()
for i in xrange(5):
zundoko.check()
Run
$ python execZundokoKiyoshi.py
Zundko ZunZunZunZunZunZunZunDokoki Yo Shi!
Zunzunzundokoki yo shi!
DoCoMo Dokodoko Zundoko Zundoko DoCoMo Dokodoko Zunzun DoCoMo Dokodoko Zundoko Zunzunzun DoCoMo Zundoko DoCoMo Dokodoko Dokodoko Zundoko DoCoMo Zundoko DoCoMo Zunzun DoCoMo Zunzun DoCoMo Zundoko Zunzun DoCoMo Zunzun DoCoMo Zundoko Dokodoko Dokodoko Dokodoko Zunzun DoCoMo Dokodoko Zunzunzun DoCoMo Zundoko Zundoko Zundoko DoCoMo Zunzunzun Dokodoko Zundoko DoCoMo Zunzunzun Zundoko Ki Yo Shi!
Zunsundoko Zunzundoko Zunzundoko Zunzundokoki!
Zunsundokodokodokodokodokozundokodokozunzundokozundokozundokodokodokodokodokodokodokodokodokodokodokozun!
My eyes are fluffy w
Recommended Posts