Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- def check(correct, user_input)
- copy = correct.dup
- size = correct.size
- hit = 0
- user_input.chars.each do |c|
- begin
- copy[/#{c}/] = ''
- hit += 1
- rescue
- break
- end
- end
- hit * 100 / size
- end
- def qestion
- @word ||=<<-'EOS'.gsub(/\s+/,'').chars
- あいうえおぁぃぅぇぉかきくけこがぎぐげごさしすせそ
- ざじずぜぞたちつってとだぢづでどなにぬねのはひふへほ
- ばびぶべぼまみむめもやゆよわをん
- EOS
- 5.times.map { @word.sample 1 }.flatten.join
- end
- def main
- 1.times do
- q = qestion
- puts q
- user_input = gets.chomp
- puts "#{check(q, user_input)} point"
- end
- end
- main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement