ACTOR = %w/digi petit rabi gema piyo/ def digi?(voice) voice =~ /nyo[^a-zA-Z0-9 ]{0,3}\Z/ end def petit?(voice) voice =~ /nyu[^a-zA-Z0-9 ]{0,3}\Z/ end def rabi?(voice) voice =~ /[^a-zA-Z0-9 ]{0,3}/ end def gema?(voice) voice =~ /gema[^a-zA-Z0-9 ]{0,3}\Z/ end def piyo?(voice) voice =~ /pyo[^a-zA-Z0-9 ]{0,3}\Z/ end STDIN.each_line {|line| line.chomp! actor, voice = line.split(' ',2) if [actor,voice].any?{|v| v.nil?} puts "WRONG!" next end unless ACTOR.include?(actor) puts "WRONG!" next end if send(actor+'?',voice) puts "CORRECT (maybe)" else puts "WRONG!" end }