Guest User

Untitled

a guest
Jul 13th, 2022
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.45 KB | None | 0 0
  1. #!/usr/bin/ruby
  2. ACCOUNTS = 1_000_000
  3. REPETITION = 100
  4. OTP_SIZE = 6
  5.  
  6. require 'securerandom'
  7.  
  8. REPETITION.times do
  9.     guessed = Array.new(3, 0)  
  10.     for i in 0..ACCOUNTS
  11.        otp = SecureRandom.random_number(("9"*OTP_SIZE).to_i)
  12.        for j in 0..2
  13.          guessed[j] +=1 if SecureRandom.random_number(("9"*OTP_SIZE).to_i) == otp
  14.        end
  15.     end
  16.  
  17.     puts "TOTAL GUESSED: #{guessed.sum.to_s} (#{guessed[0].to_s}, #{guessed[1].to_s}, #{guessed[2].to_s})"
  18. end
Advertisement
Add Comment
Please, Sign In to add comment