Checks if a combination (a tuple of 9 digits) is a valid product equation. >>> is_combination_valid(('3', '9', '1', '8', '6', '7', '2', '5', '4')) True >>> is_combination_valid(('1', '2', '3', '4', '5', '6', '7', '8', '9')) False
(combination)
| 17 | |
| 18 | |
| 19 | def is_combination_valid(combination): |
| 20 | """ |
| 21 | Checks if a combination (a tuple of 9 digits) |
| 22 | is a valid product equation. |
| 23 | |
| 24 | >>> is_combination_valid(('3', '9', '1', '8', '6', '7', '2', '5', '4')) |
| 25 | True |
| 26 | |
| 27 | >>> is_combination_valid(('1', '2', '3', '4', '5', '6', '7', '8', '9')) |
| 28 | False |
| 29 | |
| 30 | """ |
| 31 | return ( |
| 32 | int("".join(combination[0:2])) * int("".join(combination[2:5])) |
| 33 | == int("".join(combination[5:9])) |
| 34 | ) or ( |
| 35 | int("".join(combination[0])) * int("".join(combination[1:5])) |
| 36 | == int("".join(combination[5:9])) |
| 37 | ) |
| 38 | |
| 39 | |
| 40 | def solution(): |