Sobes.tech
Junior — Senior

Counting tickets with a given sum of the first three digits

livecode

Task condition

Lucky ticket is a six-digit number where the sum of the first three digits equals the sum of the last three digits. Implement the function happy_tickets(), which takes one parameter:

• target_sum — a positive integer (1 ≤ target_sum ≤ 27)

The function should return the number of six-digit tickets where the sum of the first three digits equals target_sum.

Example 1: Input: print(happy_tickets(1)) Output: 9

Example 2: Input: print(happy_tickets(2)) Output: 36

Example 3: Input: print(happy_tickets(3)) Output: 100