Skip to content

Instantly share code, notes, and snippets.

@codesnik
Created May 27, 2014 19:13
Show Gist options
  • Save codesnik/18f7a7126262a9dc17f7 to your computer and use it in GitHub Desktop.
Save codesnik/18f7a7126262a9dc17f7 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
variants = {}
headers = [ "рон", "цумо", "рон Восток", "цумо Восток"]
%W[
1-30 1000 1100 1500 1500
1-40 1300 1500 2000 2100
2-20 1300 1500 2000 2100
2-30 2000 2000 2900 3000
2-40 2600 2700 3900 3900
3-20 2600 2700 3900 3900
3-30 3900 4000 5800 6000
3-40 5200 5200 7700 7800
4-20 5200 5200 7700 7800
4-30 7700 7900 11600 11700
2-25 1600 - 2400 -
3-25 3200 3200 4800 4800
4-25 6400 6400 9600 9600
].each_slice(5) do |header2, *answers|
variants[header2] = Hash[headers.zip(answers)]
end
# реакция на ctrl+c
trap "INT" do
exit
end
puts "как надоест, скажи 'Весна, отстань'"
loop do
header1, row = variants.to_a.sample
header2, correct_answer = row.to_a.sample
next if correct_answer == '-'
question = header1 + ' ' + header2
loop do
print question
print ": "
answer = gets.chomp
case answer
when "Весна, отстань"
puts "ну и пока"
exit
when "сдаюсь"
print "правильный ответ: "
puts correct_answer
break
when correct_answer
puts "молодец!"
break
else
puts "попробуй еще раз"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment