#!/usr/bin/env ruby #!DESCRIBE: Flash cards for table words require "io/console" data = DATA.each_line.map { |l| l.strip.split(?;) } correct = 0 total = 0 loop do get = data.sample(4) if rand(2).zero? qn = get.first.first ans = get.first.last opts = get.map(&:last).shuffle else qn = get.first.last ans = get.first.first opts = get.map(&:first).shuffle end print <<-EOT.chop #{qn} 1: #{opts[0]} 2: #{opts[1]} 3: #{opts[2]} 4: #{opts[3]} >: EOT r = $stdin.getch.to_i break unless r > 0 && r < 5 print "#{r} " if ans == opts[r - 1] puts ?✔ correct += 1 else puts ?✘ end total += 1 end puts <<-EOT Score: #{correct}/#{total} EOT __END__ kio;what tio;that io;something ĉio;everything nenio;nothing kiu;who, which tiu;that person, that one iu;someone ĉiu;everyone, every neniu;no-one, none of them kiam;when tiam;then iam;some time, ever ĉiam;always, every time neniam;never, no time kia;what kind of tia;that kind of ia;some kind of ĉia;every kind of nenia;no kind of kie;where tie;there ie;somewhere ĉie;everywhere nenie;nowhere kiel;how tiel;like that, thus iel;in some way ĉiel;in every way neniel;in no way kiom;how much tiom;that much iom;to some extent, a certain amount ĉiom;all of it, the whole amount neniom;none of it, no amount kial;why tial;for that reason ial;for some reason ĉial;for every reason nenial;for no reason kies;whose ties;their, that one's ies;someone's ĉies;everyone's nenies;no-one's