TPK algorithm: Difference between revisions

Content deleted Content added
Maerics (talk | contribs)
Ruby version: Removed distracting begin/rescue block.
Line 79:
end
</source>
 
Alternative shorter code is
<source lang="ruby">
Array.new(11) {gets.to_i}.reverse.each {|x| y = Math.sqrt(x.abs) + 5*x ** 3; puts "#{x} #{(y>400) ? 'TOO LARGE' : y}"}
</source>
 
 
Ruby handles numerical overflow by returning Infinity, which is greater than 400.