SHARE
TWEET

Equal sums left/right positions

simeonshopov Oct 23rd, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. a = int(input())
  2. b = int(input())
  3.  
  4. for num in range(a, b + 1):
  5.   num = str(num)
  6.   leftsum = int(num[0]) + int(num[1])
  7.   rightsum = int(num[3]) + int(num[4])
  8.  
  9.   if leftsum != rightsum:
  10.     if leftsum > rightsum:
  11.       rightsum += int(num[2])
  12.     else:
  13.       leftsum += int(num[2])
  14.  
  15.   if leftsum == rightsum:
  16.     print(num, end=" ")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top