TPK algorithm: Difference between revisions

Content deleted Content added
Maerics (talk | contribs)
m Ruby version: Used sqrt and abs per other implementations.
Line 51:
return sqrt(abs(t))+5*t**3
a = [int(raw_input()) for i in range(11)]
for i in rangereversed(10,-1,-1a):
yprint = f(a[i]),
y = f(i)
if y > 400:
print i, "TOO LARGE"
else:
print i, y
</source>
 
This can be made shorter at the expense of clarity:
 
<source lang="python">
from math import sqrt
f = lambda t: sqrt(abs(t))+5*t**3
a = [int(raw_input()) for i in range(11)]
for i in a[::-1]:
print i,
print "TOO LARGE" if y > 400 else f(i)
</source>