Created
June 24, 2013 22:25
-
-
Save rsayers/5854235 to your computer and use it in GitHub Desktop.
Simple console based hiragana drill tool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| pairs = [["あ","a"], | |
| ["か","ka"], | |
| ["さ","sa"], | |
| ["た","ta"], | |
| ["な","na"], | |
| ["は","ha"], | |
| ["ま","ma"], | |
| ["や","ya"], | |
| ["ら","ra"], | |
| ["わ","wa"], | |
| ["が","ga"], | |
| ["ざ","za"], | |
| ["だ","da"], | |
| ["ば","ba","pa"], | |
| ["い","i"], | |
| ["き","ki"], | |
| ["し","shi"], | |
| ["ち","chi"], | |
| ["に","ni"], | |
| ["ひ","hi"], | |
| ["み","mi"], | |
| ["り","ri"], | |
| ["ぎ","gi"], | |
| ["じ","ji"], | |
| ["ぢ","ji"], | |
| ["び","bi","pi"], | |
| ["う","u"], | |
| ["く","ku"], | |
| ["す","su"], | |
| ["つ","tsu"], | |
| ["ぬ","nu"], | |
| ["ふ","fu"], | |
| ["む","mu"], | |
| ["ゆ","yu"], | |
| ["る","ru"], | |
| ["ぐ","gu"], | |
| ["ず","zu"], | |
| ["づ","zu"], | |
| ["ぶ","bu","pu"], | |
| ["え","e"], | |
| ["け","ke"], | |
| ["せ","se"], | |
| ["て","te"], | |
| ["ね","ne"], | |
| ["へ","he"], | |
| ["め","me"], | |
| ["れ","re"], | |
| ["げ","ge"], | |
| ["ぜ","ze"], | |
| ["で","de"], | |
| ["べ","be","pe"], | |
| ["お","o"], | |
| ["こ","ko"], | |
| ["そ","so","zo"], | |
| ["と","to"], | |
| ["の","no"], | |
| ["ほ","ho"], | |
| ["も","mo"], | |
| ["よ","yo"], | |
| ["ろ","ro"], | |
| ["を","o"], | |
| ["ん","n"], | |
| ["ご","go"], | |
| ["ど","do"], | |
| ["ぼ","bo","po"]] | |
| total = 0 | |
| correct = 0 | |
| trap("INT") { puts "Final score: #{correct} out of #{total-1} correct"; exit} | |
| while true do | |
| pair = pairs[rand(pairs.size)] | |
| guessed = false | |
| while !guessed | |
| total += 1 | |
| print pair[0] | |
| print ":" | |
| guess = gets.chomp | |
| if (pair[1..-1].include?(guess)) then | |
| puts "Correct!" | |
| correct+=1 | |
| guessed = true | |
| else | |
| puts "Incorrect, try again" | |
| end | |
| puts "#{correct} out of #{total} correct" | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment