0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Ruby でいけていない ヌメロン を作ってみた

Last updated at Posted at 2020-07-18

はじめに

とある事情により、いけていないヌメロンを作ってみた。
後悔はしていない。

Numer0n - wikipedia

いけている ヌメロン

こちらの記事を参照しました。
[Ruby]数当てゲームのヌメロン作ってみた

ソースコード

numeron.rb
d = []
while true
  d[102, 2] = rand(0..32767).divmod(10)
  d[101, 2] = rand(0..32767).divmod(10)
  d[100, 2] = rand(0..32767).divmod(10)
  break if d[101] != d[102] && d[102] != d[103] && d[103] != d[101]
end
puts "コールしてください"
while true
  x200 = gets.chomp
  d[111] = x200[0].to_i
  d[112] = x200[1].to_i
  d[113] = x200[2].to_i
  d[300] = 0
  d[400] = 0
  d[300] += 1 if d[101] == d[111]
  d[300] += 1 if d[102] == d[112]
  d[300] += 1 if d[103] == d[113]
  d[400] += 1 if d[101] == d[112]
  d[400] += 1 if d[101] == d[113]
  d[400] += 1 if d[102] == d[111]
  d[400] += 1 if d[102] == d[113]
  d[400] += 1 if d[103] == d[111]
  d[400] += 1 if d[103] == d[112]
  if d[300] == 3
    puts "3 EAT"
    break
  else
    puts "#{d[300]} EAT - #{d[400]} BITE"
  end
end
rand.rb
  d[100, 2] = rand(0..32767).divmod(10)

  d[101] = rand(0..9)

rand(0..9)とリファクタリングしてはいけない。
こちらにも都合というものがあるです。

まとめ

  • いけていない ヌメロンを作ってみた
  • 後悔 はしていない
  • Ruby に詳しくなった
0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?