LoginSignup
13
7

More than 5 years have passed since last update.

Get,GetGetGetWildAndTough!

Last updated at Posted at 2017-07-19

コード

GET = "Get"
WILD = "Wild"
AND = "and"
TOUGH = "Tough"

getWildAndTough = [GET,WILD,AND,TOUGH]
getChanceAndLuck = [9,9,9]

while(true) do
    gwat = rand(0..2)
    puts getWildAndTough[gwat]
    getChanceAndLuck.shift
    getChanceAndLuck.push(gwat)
    dream = true
    getChanceAndLuck.each_with_index{|wild,tough| dream = (wild == tough) && dream}
    break if dream
end 
puts getWildAndTough[3]

出力

and
Wild
Wild
Wild
and
Get
Get
Wild
Get
and
Wild
Wild
Get
Get
Wild
Wild
Get
Wild
Get
Wild
and
Tough

なにこれ?

一人では解けない愛のパズル

仕様

「Get」 「Wild」 「and」 をランダムに出力します。
「Get Wild and」の順に出力されたら「Tough」と出力して終了します。

元ネタ

http://qiita.com/shunsugai@github/items/971a15461de29563bf90 by @shunsugai@github

更新履歴

開幕でWild andするとToughしちゃうバグをサイレント修正
HASHを辞めて配列に

13
7
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
7