Ctrl K

Tickets with an Even Digit Sum

Easy
Lottery tickets are numbered from 1 to limit. A ticket is lucky when the digits of its number add up to an even value. Return how many lucky tickets there are among the numbers 1 through limit inclusive.
Example 1
limit=12 → 5

The numbers 2, 4, 6, 8 and 11 have an even digit sum, five in total.

Example 2
limit=1 → 0

The digit sum of 1 is odd, so no ticket qualifies.

Example 3
limit=25 → 12

2, 4, 6, 8, 11, 13, 15, 17, 19, 20, 22 and 24 qualify, which is 12 tickets.

Constraints
  • 1 ≤ limit ≤ 1000
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsSum of Binary Strings EasyFold the Digits Down to One EasyCounting Off by Threes and Fives EasyAdding Long Numbers in Strings EasyGrowing Handouts Around the Circle Easy
loading Python…
Input
limit=12
Expected
5

Run checks the first 3 tests in your browser. Submit checks all 37 tests on the server, hidden ones included.