This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a array with numbers from 1 to 100 in a random order | |
ary = (1..100).to_a.shuffle + (1..100).to_a.shuffle | |
idx = 0 | |
paired = ary.map.with_index { |value| [value, idx += 1] } | |
# Now the numbers are paired; the first is the random number 1-100 the second is its sequence within the 200 entries | |
puts paired.inspect | |
# You'll see many entries with equal first values where the first of them has a higher second (sequence) number, meaning it's out of order now |