Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- start_num = int(input())
- final_num = int(input())
- for num in range(start_num, final_num + 1):
- sum_odd = 0
- sum_even = 0
- digit = num
- for n in range(6):
- if n % 2 == 0:
- sum_odd += digit % 10
- else:
- sum_even += digit % 10
- digit //= 10
- if sum_odd == sum_even:
- print(num, end=' ')
- РЕШЕНИЕ СЪС STR():
- start_num = int(input())
- final_num = int(input())
- for num in range(start_num, final_num + 1):
- sum_odd = 0
- sum_even = 0
- current = str(num)
- for n in range(len(current)):
- digit = current[n]
- if n % 2 == 0:
- sum_odd += int(digit)
- else:
- sum_even += int(digit)
- if sum_odd == sum_even:
- print(num, end=' ')
- РЕШЕНИЕ С ЛИСТ леко тарикатската:)
- lst = list(range(int(input()), int(input()) + 1))
- while len(lst) != 0:
- num = list(map(int, str(lst.pop(0))))
- if sum(num[1::2]) == sum(num[0::2]):
- print(''.join(map(str, num)), end=' ')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement