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 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 solve the tribonacci sequence problem in Ruby, with recursion.
I tried to make a talk application in Java using AI "A3RT"
[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 wanted to make (a == 1 && a == 2 && a == 3) true in Java
[Ruby basics] I tried to learn modules (Chapter 1)
I tried to output multiplication table in Java
I tried to create Alexa skill in Java
I want to get the value in Ruby
I tried to solve the tribonatch sequence problem in Ruby (time limit 10 minutes)
# 2 [Note] I tried to calculate multiplication tables in Java.
I tried to create a Clova skill in Java
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 bonus drink problem (there is an example of the answer)
I want to perform high-speed prime factorization in Ruby (ABC177E)
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
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 using Dapr in Java to facilitate microservice development
I tried to implement a buggy web application in Kotlin
I tried to summarize object orientation in my own way.
I tried DI with Ruby
I tried to verify yum-cron
I tried metaprogramming in Java
I tried to solve the Ruby bingo card creation problem (there is an example of the answer)
After learning Progate, I tried to make an SNS application using Rails in the local environment
I tried to solve the problem of "multi-stage selection" with Ruby
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
Summary of problems that I could not log in to firebase
[Ruby] Tonight, I tried to summarize the loop processing [times, break ...]
I tried setting Java beginners to use shortcut keys in eclipse
I tried to reimplement Ruby Float (arg, exception: true) with builtin
I tried to make an Android application with MVC now (Java)
I tried to understand how the rails method "link_to" is defined
I tried to summarize devise which was difficult at first glance
I tried to make it an arbitrary URL using routing nesting
[Java] I tried to make a maze by the digging method ♪
Collatz number, Fibonacci number, triangular number I tried to make various sequence programs
I want to change the value of Attribute in Selenium of Ruby