fork download
  1. from fractions import*
  2. from collections import*
  3.  
  4. X={(1,0,0,0):1,(-1,0,0,0):1}
  5.  
  6. for i in xrange(10):
  7. Y=defaultdict(lambda:0)
  8. n=d=0
  9. for a,b,s,t in X:
  10. c=X[(a,b,s,t)]
  11. for A in ( (1,-1) if i else [a] ):
  12. for B in 1,0,0,-1:
  13. n+=c*(s+A*B==0==t+A*b+a*B)
  14. d+=c
  15. Y[(a,B,s+A*B,t+A*b)]+=c
  16. print Fraction(n,d)
  17. X=Y
Success #stdin #stdout 0.06s 8656KB
stdin
Standard input is empty
stdout
1/2
3/8
7/32
89/512
269/2048
903/8192
3035/32768
169801/2097152
599569/8388608
2155307/33554432