fork download
  1. # your code goes here
  2. n = [2,4,7,1,6,3,8,5,10,9,12]
  3. i = 0
  4. j = len(n)-1
  5. p1 = 0
  6. p2 = 0
  7. while(j>=i):
  8. if(n[i]%2 != 0):
  9. p1 += n[i]
  10. i += 1
  11.  
  12. else:
  13. p2 += n[i]
  14. i += 1
  15. while(n[j]%2 !=0):
  16. p1 += n[j]
  17. j -= 1
  18. p2 += n[j]
  19. j -= 1
  20.  
  21. ans = abs(p2-p1)
  22. print(ans)
Success #stdin #stdout 0.08s 7904KB
stdin
Standard input is empty
stdout
17