fork(1) download
  1. #https://i...content-available-to-author-only...e.com/XKyhyR
  2.  
  3. n = 42;
  4. #rev = 0
  5. new= []
  6. m = 0
  7.  
  8. def convert(n,m):
  9. print "round #:", m,"n :", n
  10. a = ((n+1) % 3)-1
  11. if n:
  12. new.append(a); print 'new :', new
  13. print 'call convert(', (n+1)//3,',',m+1,'):', convert((n+1)//3,m+1)
  14. print 'after convert(' , n, ',' ,m, ')','\n'
  15. else:
  16. print 'n==',n, 'new: ::: ', new,'\n\n',
  17. return new, n
  18.  
  19. print convert(n,m), "<<---- None returned ? "
  20.  
  21. sum = 0
  22.  
  23. def value(l):
  24. sum = 0
  25. for i in range(0, len(new),1):
  26. sum += new[i]*(3**i)
  27. print "sum :" , sum
  28. return sum
  29.  
  30. #print value(new),
Success #stdin #stdout 0.01s 7256KB
stdin
Standard input is empty
stdout
round #: 0 n : 42
new : [0]
call convert( 14 , 1 ): round #: 1 n : 14
new : [0, -1]
call convert( 5 , 2 ): round #: 2 n : 5
new : [0, -1, -1]
call convert( 2 , 3 ): round #: 3 n : 2
new : [0, -1, -1, -1]
call convert( 1 , 4 ): round #: 4 n : 1
new : [0, -1, -1, -1, 1]
call convert( 0 , 5 ): round #: 5 n : 0
n== 0 new: :::  [0, -1, -1, -1, 1] 

([0, -1, -1, -1, 1], 0)
after convert( 1 , 4 ) 

None
after convert( 2 , 3 ) 

None
after convert( 5 , 2 ) 

None
after convert( 14 , 1 ) 

None
after convert( 42 , 0 ) 

None <<---- None returned ?