You are quite correct. My brainfarts are legendary. When I said 20 and 54, I did of course mean 20 levels and 54 levels...... 20 levels are 1540 balls and 54 levels are 27720 balls. 55 levels are 29260 balls. Simplified, it can be done:
def onelev(x):
'''The x defines number of balls in a single level given the formula f(x)=(x^2)/2+(x/2)'''
return int((float(x)*float(x))/2.0)+(float(x)/2.0))
def tetra(x):
'''The x defines number of levels of balls in the tetrahedron'''
return sum([onelev(y) for y in range(1,x+1)])
tetra(20)
1540
tetra(54)
27720
tetra(55)-tetra(20)
27720
So I guess my answer was in part correct although not very accurate :) But, looking above, there is a smaller answer ( which I haphazardly ignored since I started to work up from 10 :p ) >>> searchtetra(2,18) 560 120 680 14 8 15 My bad there (yeah, don't solve puzzles while working - you don't have time to verify your mess haha :) )
I=I.am()?Code(I):0/0;