Newer
Older
Ruby / word_memorize.rb
@YUKI Maoko YUKI Maoko on 23 Sep 2024 382 bytes 2024-09-23 23:18:31
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}点です。"