Interviewstreet CS 2 - Coin Tosses

Quite easy if you closely read the question. My solution is in Python:
Spoiler
import sys
def probHeads(n):
if n == 0:
return 0
d = pow(2,n)
sum = 0
for x in range(1, n+1):
sum += d * x / pow(2,x)
sum += d * x / pow(2,x)
return sum
def solve(n, m):
solution = probHeads(n) - probHeads(m)
return solution if solution > 0 else 0
amount = 0
while True:
line = raw_input()
if amount == 0:
limit = line
else:
(n,m) = line.split(" ")
print "%.2f" % solve(n,m)
amount += 1
if amount == limit:
sys.exit(0)
, never thought of it xD, I like how you keep trying to make the code smaller every time and everywhere so ima try to do that too which helps you to understand programming better and learn different ways of doing different things 