require 'csv'

words = []
CSV.foreach( 'words.csv' ) do |row|
  words << row[0]
end

score = 0
index = 0

while index < words.length
  word = words.sample
  puts "単語 #{word}"
  print "入力: "
  input = gets.chomp
  
  if input == word
    puts "正解!"
    score += 10
  else
    puts "間違い!"
  end

  index += 1
end

puts "あなたのスコアは#{score}点です。"
