$word = Array.new(5,97) # a = 97 digit = 1 def countup(digit) # def の引数指定が、この方法でよいのか、よく分からない $word[digit] += 1 if $word[digit] == 123 $word[digit] = 97 # zを 越えたら a にリセット digit += 1 countup(digit) end digit = 1 end (gets.to_i - 1).times do puts "a" + $word.each.map(&:chr).join + "a" countup(digit) end puts "a" + $word.each.map(&:chr).join + "n"