f={ 'digi'=>lambda{|s|s=~/nyo\W{0,3}$/}, 'petit'=>lambda{|s|s=~/nyu\W{0,3}$/}, 'rabi'=>lambda{|s|s=~/\w/}, 'gema'=>lambda{|s|s=~/gema\W{0,3}$/}, 'piyo'=>lambda{|s|s=~/pyo\W{0,3}$/}, } f.default=lambda{|s|nil} $<.each{|e| a=e.chomp.split(' ',2) puts f[a[0]][(a[1]||'').downcase] ? 'CORRECT (maybe)' : 'WRONG!' }