Advertisement
mfgnik

Untitled

May 27th, 2020
1,008
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.69 KB | None | 0 0
  1. def digit_sum(number):
  2.     return sum(map(int, list(str(number)))) % 2
  3.  
  4.  
  5. def calculate_little(begin, end):
  6.     result = 0
  7.     for number in range(begin, end + 1):
  8.         if digit_sum(number):
  9.             result += 1
  10.     return result
  11.  
  12.  
  13. result = 0
  14. begin, end = int(input()), int(input())
  15. if end - begin < 1000 or True:
  16.     print(calculate_little(begin, end))
  17. else:
  18.     fill = []
  19.     old_begin, old_end = begin, end
  20.     while begin % 10 != 1:
  21.         fill.append(begin)
  22.         begin += 1
  23.     while end % 10 != 0:
  24.         fill.append(end)
  25.         end -= 1
  26.     print(fill, begin, end)
  27.     print((end - begin) // 2 + sum(map(digit_sum, fill)) + (old_end - old_begin) // 10 % 2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement