Skip to content

Instantly share code, notes, and snippets.

@rotelstift
Created March 12, 2016 05:49
Show Gist options
  • Select an option

  • Save rotelstift/afe3cd36926d56c86e1e to your computer and use it in GitHub Desktop.

Select an option

Save rotelstift/afe3cd36926d56c86e1e to your computer and use it in GitHub Desktop.
def sing
if Random.rand > 0.5 then
print("ズン ")
return 1
else
print("ドコ")
return 0
end
end
###### main ######
kiyoshi = "き・よ・し!"
zun_counter = 0
sang = 0
# 『ズン』が4回以上繰り返され、『ドコ』が出力された時に終わるループ
# 『ズン』が4回未満のときに『ドコ』が出たら『ズン』のカウントはリセットされる
until zun_counter >= 4 && sang == 0 do
if sang == 0 then
zun_counter = 0
print("\r")
print("                  ")
print("\r")
end
sang = sing()
zun_counter = zun_counter + sang
sleep(1)
end
print("\n")
puts(kiyoshi)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment