Lottery tickets (lottery)

44 teams scored 1100 points on this task, for a maximum score of 25, an average score of 25 and a median score of 25.

Highlights

  1. Galileo Galilei, Trento is the institute with the most points (50).
  2. Veneto is the region with the most points (175).

Statement

Tommaso would like to buy a new computer but unfortunately he doesn't have enough money. So he decided to try his luck and buy some lottery tickets. The lottery tickets are numbered, and one of his friends told him the secret to win the lottery: in a winning ticket the sum of the digits of the ticket number is exactly N and the ticket number does not contain 3 consecutive equal digits. When Tommaso arrived to the lottery shop, he saw that some tickets were already sold. The current ticket number is S and Tommaso must buy the tickets in order (first ticket number S, then ticket number S+1, then ticket number S+2, and so on). He wants to buy some tickets until he finds a winning one. Note that it is possible that Tommaso is not able to buy a winning ticket. What is the number of the winning ticket bought by Tommaso? Help Tommaso to find the answer in T different scenarios.