Why "wrong answer" (1001 - Ruby)
My code:
a = readlines
a = a.join
a = a.split(/\s+/)
a.reverse!
a.map!{|elem|elem.to_i}
a.map!{|elem|(elem**0.5).round(4)}
puts a
I've tried code from FAQ page:
tokens = []
while string = gets do
string.split().each do |token|
tokens << token
end
end
tokens.reverse.each do |token|
puts (token.to_i ** 0.5).round(4)
end
Both variants return right results in my terminal, but in both cases i've got "wrong answer" here.
Why?