Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tickets = input()
- SYMBOLS = ('@', '#', '$', '^')
- def sanitize(a: str):
- a = a.split(',')
- a = [x.strip() for x in a]
- return a
- def valid_length(b: str):
- return len(b) == 20
- def split(lst: str):
- h1 = lst[:10]
- h2 = lst[10:]
- return h1, h2
- def check_match(h1:str, h2:str):
- found = False
- result = []
- for x in SYMBOLS:
- combination = x * 6
- if combination in h1 and combination in h2:
- win_count = min(h1.count(x), h2.count(x))
- found = True
- result = [x, win_count]
- if found:
- return result
- def win_length(a: str, num: int):
- if num < 10:
- print(f'ticket "{ticket}" - {num}{a}')
- else:
- print(f'ticket "{ticket}" - {num}{a} Jackpot!')
- tickets = sanitize(tickets)
- for ticket in tickets:
- if not valid_length(ticket):
- print('invalid ticket')
- else:
- half_1, half_2 = split(ticket)
- if not check_match(half_1, half_2):
- print(f'ticket "{ticket}" - no match')
- else:
- symbol, count = check_match(half_1, half_2)
- win_length(symbol, count)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement