[Ruby] Aizu Onene Judge

less than 1 minute read

This article is made as a memorandum so that you will not forget what you learned while working on Aizu Online Judge.

gets (accepts string input)

name = gets
Enter #Taro and enter
#=>"Taro\n"
name = gets.chomp
Enter #Taro and enter
#=>"Taro"
number = gets.to_i
Enter #1
#=>1

gets is a string

join

Concatenate arrays and return as one string

[1,2,3].join
#"abc"
[1,2,3].join(" ")
#"a b c"
[1,2,3].join("+")
#"1+2+3"

repetition

times

1000.times do
   puts "Hello World"
end

Tags:

Updated: