How is the progress?
Clojure that randomly displays "Progress, how, how," and when "How is progress" is completed A program that randomly displays "Progress, how, how," and incites when "How is progress" is completed I wrote "Progress, how, how" in Haskell How is the progress? Let's try ruby on the boom?
I wrote it in Python. It's just a matter of writing, so I tried using a lambda expression that I rarely use (list comprehension is too convenient).
shinchoku.py
#coding: utf-8
import random
li = ["progress","How","is","Or"]
LI_RAND_LENGTH = len(li)-1
CHECK_NUM = -len(li)
ret = []
itr = 0
shinchokuStr = lambda : li[random.randint(0,LI_RAND_LENGTH)]
appendShinchoku = lambda l : l+[shinchokuStr()]
last4Strs = lambda l : "".join(l[CHECK_NUM:])
loopCheck = lambda x, y : last4Strs(x) == last4Strs(y)
while(not loopCheck(li,ret)) :
ret = appendShinchoku(ret)
itr += 1
print ret[-1],
print "\n"+str(len("".join(ret))/3)+"Fanned by letters"
$ python shinchoku.py
How is it? How is it? How is it? How is it progress? How is progress. Progress is progress. How is progress? Progress is progress. Progress is progress. Progress is progress. Progress is progress. Progress is progress. Progress is progress. It ’s progress, it ’s progress, it ’s progress, it ’s progress, it ’s progress, it ’s progress, it ’s progress, it ’s progress, it ’s progress, it ’s progress, it ’s progress, it ’s progress, it ’s progress, it ’s progress. Is it progress? How is progress? How is progress? How is progress? Progress is progress. Is it progress? Is it progress? How is it? How is it? Progress progress progress How is progress Progress is progress How is progress How is progress How is progress? It's progress, it's progress, it's progress, it's progress, it's progress, it's progress, it's progress, it's progress, it's progress, it's progress, it's progress, it's progress, it's progress, it's progress, it's progress, it's progress. How is it? Progress progress or progress is progress How is progress How is progress How is progress How is progress Progress is progress Progress is progress How is progress Progress is progress How is progress or is progress How is progress? How is the progress? How is the progress? How is the progress? How is the progress? How is the progress? How is the progress? How is the progress? How is the progress? How is the progress? How is the progress? How is the progress? How is it progress? How is progress? Is it progress? Is it progress? Is it progress? Is it progress? Is it progress? Is it progress? Is it progress? Is it progress? Is it? How is it? Progress progress Progress progress Is it progress? Is it progress? How is it? How is it?
Fanned by 656 characters
lambda expression is fun. By the way, I said that I should study Haskell, so I want to study. Also, it seems that the length of the Python character string varies depending on the character code (?). For the time being, it worked, so I put in a magic number.
Recommended Posts