Guest User

Untitled

a guest
May 27th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. # usage: ruby air.rb
  2.  
  3. L = Hash[("a".."f").map.with_index {|e,i| [e,i+1] }]
  4. LL = L.invert
  5. c = File.read("air-pytania.txt").split("\n\n").sort_by { rand }[0...10].map do |q|
  6. p = q.split("\n")
  7. puts p.first
  8.  
  9. correct = 0
  10.  
  11. (1...p.size).each do |i|
  12. correct = i if p[i] =~ /\* (.+)/
  13. puts LL[i] + ") " + p[i].gsub(/\*|-/, '')
  14. end
  15.  
  16. print "Odp: "
  17. ans = gets.chomp
  18.  
  19. if ans == LL[correct]
  20. puts "Dobrze!"
  21. puts
  22. 1
  23. else
  24. puts "Dupa. Poprawna odpowiedz to: #{LL[correct]}"
  25. puts
  26. 0
  27. end
  28. end.inject(0){|s,e| s + e}
  29. puts
  30. puts
  31. puts "Wynik: #{c}/10"
Add Comment
Please, Sign In to add comment