Created
June 27, 2022 05:22
-
-
Save shakayami/ca1bf2410a0dbe74ebd06c55d261516a 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
''' | |
https://twitter.com/kumiromilk/status/707437861881180160 | |
Javaの講義、試験が「自作関数を作り記述しなさい」って問題だったから | |
「ズン」「ドコ」のいずれかをランダムで出力し続けて「ズン」「ズン」「ズン」「ズン」「ドコ」の配列が出たら「キ・ヨ・シ!」って出力した後終了って関数作ったら満点で単位貰ってた | |
''' | |
import random | |
from collections import deque | |
deq=deque([]) | |
while(True): | |
deq.append(random.randrange(2)) | |
if deq[-1]==1: | |
print("ズン",end=" ") | |
else: | |
print("ドコ",end=" ") | |
if len(deq)>=5 and (deq[-5],deq[-4],deq[-3],deq[-2],deq[-1])==(1,1,1,1,0): | |
print("キ・ヨ・シ!") | |
break | |
if len(deq)>5: | |
deq.popleft() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment