Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 10. Winning Ticket , Text Processing - Exercise 100/100
- # https://judge.softuni.org/Contests/Compete/Index/1740#9
- def calculate_value(some_side, spec_symbol):
- final_string = 0
- symbol_string = f"{spec_symbol * 6}"
- if symbol_string in some_side:
- final_string = len(symbol_string)
- symbol_string = f"{spec_symbol * 7}"
- if symbol_string in some_side:
- final_string = len(symbol_string)
- symbol_string = f"{spec_symbol * 8}"
- if symbol_string in some_side:
- final_string = len(symbol_string)
- symbol_string = f"{spec_symbol * 9}"
- if symbol_string in some_side:
- final_string = len(symbol_string)
- symbol_string = f"{spec_symbol * 10}"
- if symbol_string in some_side:
- final_string = len(symbol_string)
- return int(final_string)
- def is_ticked_valid(some_ticket):
- if len(some_ticket) == 20:
- return True
- print('invalid ticket')
- return False
- def is_ticked_contain_special_symbols(some_ticket):
- for smbl in some_ticket:
- if smbl in winners_symbols:
- return True
- print(f'ticket "{ticket}" - no match')
- return False
- def symbol_finder(some_ticket):
- for char1 in some_ticket:
- if char1 in winners_symbols:
- searched_symbol = char1
- return searched_symbol
- all_tickets = input().split(',')
- winners_symbols = ['@', '#', '$', '^']
- start_index = 0
- for ticket in all_tickets:
- ticket = ticket.strip()
- if is_ticked_valid(ticket) and is_ticked_contain_special_symbols(ticket):
- matched_symbol = symbol_finder(ticket)
- left_side = ticket[:10]
- right_side = ticket[10:]
- result1 = calculate_value(left_side, matched_symbol)
- result2 = calculate_value(right_side, matched_symbol)
- if result1 >= 6 and result2 >= 6:
- win_value = min(result1, result2)
- if result1 == 10 and result2 == 10:
- print(f'ticket "{ticket}" - {int(win_value)}{matched_symbol} Jackpot!')
- else:
- print(f'ticket "{ticket}" - {int(win_value)}{matched_symbol}')
- else:
- print(f'ticket "{ticket}" - no match')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement