Ruby: TPK Algorithm in Different Programming Languages

I was looking for some exercise problems for a programming class I am teaching and encountered Knuth’s TPK problem on http://cs.fit.edu/~ryan/compare/┬ácomparing solutions in different languages but did not find my favorite language and thought I would do it in Ruby and may be submit for inclusion there.

The TPK algorithm reads in an array of 11 values, applies a particular function to each value, and then writes the result in reverse order. It serves just to illustrate some of the usual actions that an imperative programming language must perform.

Here is my quick solution:

#
# http://cs.fit.edu/~ryan/compare/
#
inputs = []

def f(x)
Math.sqrt(x.abs) + (5 * x ** 3)
end

11.times do
inputs << gets.chomp.to_f
end

inputs.reverse.each_with_index do |num, index|
fn = f(num)
if fn < 400
puts "#{10 - index} #{fn}"
else
puts "#{10 - index} #{fn} TOO LARGE"
end
end

I think it could be done better but just wanted to have something out there.