From a79414bcf14d17c58e040a7b8524f7bd8f7e5e03 Mon Sep 17 00:00:00 2001 From: Nat Lasseter Date: Mon, 22 Jan 2024 10:23:58 +0000 Subject: Migrate from gists --- tabelvortoj.rb | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 tabelvortoj.rb (limited to 'tabelvortoj.rb') diff --git a/tabelvortoj.rb b/tabelvortoj.rb new file mode 100644 index 0000000..2e85ccd --- /dev/null +++ b/tabelvortoj.rb @@ -0,0 +1,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 -- cgit v1.2.1