I tried to make Numeron which is not good in Ruby

Introduction

For some reason, I tried to make a bad Numeron. I have no regrets.

Numer0n - wikipedia

Going Numeron

I referred to this article.

Source code

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 "Please call"
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)

Do not refactor with rand (0..9). There is something convenient here as well.

Summary

Recommended Posts

I tried to make Numeron which is not good in Ruby
I tried to make a parent class of a value object in Ruby
I tried to make full use of the CPU core in Ruby
I tried to make a login function in Java
I tried to make FizzBuzz that is uselessly flexible
I tried to make an application in 3 months from inexperienced
I tried to make a client of RESAS-API in Java
I tried to write code like a type declaration in Ruby
I tried a calendar problem in Ruby
What is Docker? I tried to summarize
I tried to build Ruby 3.0.0 from source
I tried to solve the tribonacci sequence problem in Ruby, with recursion.
[Ruby] I tried to summarize the methods that frequently appear in paiza
[Ruby] I tried to summarize the methods that frequently appear in paiza ②
I tried to make Basic authentication with Java
I tried to implement polymorphic related in Nogizaka.
I tried to organize the session in Rails
I want to use arrow notation in Ruby
I tried to implement deep learning in Java
I wanted to make (a == 1 && a == 2 && a == 3) true in Java
I tried to output multiplication table in Java
I tried to develop an application in 2 languages
I want to get the value in Ruby
I tried to organize the cases used in programming
I tried to implement Firebase push notification in Java
# 2 [Note] I tried to calculate multiplication tables in Java.
I tried to create a Clova skill in Java
I tried to make FizzBuzz that is uselessly flexible
I tried to implement the Euclidean algorithm in Java
~ I tried to learn functional programming in Java now ~
I tried to find out what changed in Java 9
I tried to solve the Ruby karaoke machine problem (there is an example of the answer)
I tried to solve the Ruby bonus drink problem (there is an example of the answer)
I tried to make an introduction to PHP + MySQL with Docker
I tried to make Venn diagram an easy-to-understand GIF animation
I just wanted to make a Reactive Property in Java
I tried to make Java Optional and guard clause coexist
What I did in the version upgrade from Ruby 2.5.2 to 2.7.1
I tried to summarize the basic grammar of Ruby briefly
I tried to convert a string to a LocalDate type in Java
I want to create a Parquet file even in Ruby
I tried to automate LibreOffice Calc with Ruby + PyCall.rb (Ubuntu 18.04)
I tried using Dapr in Java to facilitate microservice development
I tried to summarize object orientation in my own way.
I tried DI with Ruby
Ruby # {} is not variable expansion
I tried to verify yum-cron
I tried Jets (ruby serverless)
I tried metaprogramming in Java
I tried to make the "Select File" button of the sample application created in the Rails tutorial cool
I tried to solve the Ruby bingo card creation problem (there is an example of the answer)
Since the Rspec command is troublesome, I tried to make it possible to execute Rspec with one Rake command
After learning Progate, I tried to make an SNS application using Rails in the local environment
I tried to create an API to get data from a spreadsheet in Ruby (with service account)
I tried to summarize the words that I often see in docker-compose.yml
I tried to create a simple map app in Android Studio
I tried to implement Ajax processing of like function in Rails
When I try to put centos in VMware, pane is dead
I tried to illuminate the Christmas tree in a life game
I tried to sort the data in descending order, ascending order / Rails
[Rails] What to do if data is not registered in DB