Skip to content

Instantly share code, notes, and snippets.

@User4574
Created May 12, 2023 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save User4574/d7c9e47e8ad324ef047b21aa01b69457 to your computer and use it in GitHub Desktop.
Save User4574/d7c9e47e8ad324ef047b21aa01b69457 to your computer and use it in GitHub Desktop.
Tabelvortoj test
#!/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment