#!/usr/bin/env ruby
# -*- coding: utf-8 -*-

puts("タイピングゲーム!")
puts("出てくる文字をタイピングしてね")
bun=["フライドポテト","お飲み物","宮沢賢治","コーンポタージュ","なぞなぞ","以後、お見知りおきを","1234567890","ジュニアドクター鳥海塾","朝鮮民主主義人民共和国","マクガフィン"]
ro_mazi=["furaidopoteto","onomimono","miyazawakenzi","ko-npota-ju","nazonazo","igo,omishiriokiwo","1234567890","juniadokuta-tyoukaijuku","tyousenminsyusyugizinminkyouwakoku","makugafin"]
srand()
x=rand(10)
puts(bun[x],ro_mazi[x])
hazime=Time.now
uttabun=gets.chomp
owari=Time.now
time=owari-hazime
printf("約%3.2f秒でした。\n",time)
r=ro_mazi[x]
y=0
z=-1
n=[]
m=0
while y<=ro_mazi[x].length
  if r[y]==uttabun[y]
    z += 1
  else
    n<<y
    m += 1
  end
  y += 1
end

l=0
if z==ro_mazi[x].length
  puts("全部あってるよ すごい!")
else
  puts("残念…")
  while l<m
    print(n[l],",")
    l += 1
  end
  puts("文字目が間違ってたよ")
end

score=ro_mazi[x].length*10-n.length-time
printf("スコアは%fでした。\n",score)
