Lucky Sevens
Easy · math
At the village fair, a raffle has printed a pile of tickets. You are given a list tickets of ticket numbers, each a whole number written in ordinary decimal digits (so 1707 is written 1, 7, 0, 7).
Seven is the lucky digit. Every 7 printed on a ticket brings the village one lucky point, so a ticket with two sevens brings two.
Return the total number of 7 digits printed across all the tickets. If the list is empty, return 0.
Examples
Example 1
Input: tickets = [7, 77, 1707]
Output: 5
The ticket 7 has one seven, 77 has two and 1707 has two, which makes 5.
Example 2
Input: tickets = [123, 456, 890]
Output: 0
Example 3
Input: tickets = [700000007, 0]
Output: 2
The first ticket has a seven at each end. The ticket 0 is written with a single digit, 0.
Constraints
- 0 <= len(tickets) <= 1000
- 0 <= tickets[i] <= 10^9