aboutsummaryrefslogtreecommitdiff
path: root/tabelvortoj.rb
blob: 2e85ccdf0d00826d40fe132b85e248b4974ccd57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/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