BbJLeB

05. Equal Sums Left Right Position

Jun 4th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. # 05. Equal Sums Left Right Position
  2.  
  3. import math
  4.  
  5. n1 = int(input())
  6. n2 = int(input())
  7. x1 = 0
  8. x2 = 0
  9. x3 = 0
  10. x4 = 0
  11. x5 = 0
  12.  
  13. for i in range(n1, n2 + 1):
  14.     x1 = math.floor(i / 10000) % 10
  15.     x2 = math.floor(i / 1000) % 10
  16.     x3 = math.floor(i / 100) % 10
  17.     x4 = math.floor(i / 10) % 10
  18.     x5 = i % 10
  19.     leftSum = x1 + x2
  20.     rightSum = x4 + x5
  21.     if leftSum == rightSum:
  22.         print(f"{i} ", end="")
  23.     else:
  24.         if leftSum > rightSum:
  25.             rightSum += x3
  26.             if leftSum == rightSum:
  27.                 print(f"{i} ", end="")
  28.         else:
  29.             leftSum += x3
  30.             if leftSum == rightSum:
  31.                 print(f"{i} ", end="")
Add Comment
Please, Sign In to add comment