RosettaCodeData/Task/Number-reversal-game/Ruby/number-reversal-game.rb
Ingy döt Net b83f433714 tasks a-s
2013-04-10 23:57:08 -07:00

11 lines
272 B
Ruby

ary = (1..9).to_a
ary.shuffle! while ary == ary.sort
score = 0
until ary == ary.sort
print "#{ary.inspect} -- How many digits to reverse? "
num = gets.to_i # should validate input
ary[0, num] = ary[0, num].reverse
score += 1
end
p ary
puts "Your score: #{score}"