Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Swedish car plates: ABC123
- where 123 must be either
- 1 + 2 = 3 // right
- 1 - 2 = 3 // wrong
- 1 * 2 = 3 // wrong
- 1 / 2 = 3 // wrong
- => Is a valid plate,
- cuz one arithmetic operation works
- and the third number can be created using one of these
- arithmetic operations in the correct order of the numbers.
- """
- valid_numbers = [int(i) for i in range(10)]
- alphabet = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
- num_letter_combinations = len(alphabet) ** 3
- result = set()
- num_number_combinations = 0
- for i in range(10):
- for j in range(10):
- if i + j in valid_numbers:
- r = i * 100 + j * 10 + (i + j)
- result.add(r)
- print(i, "+", j, "=", i + j, ";%03d" % r)
- if i - j in valid_numbers:
- r = i * 100 + j * 10 + (i - j)
- result.add(r)
- print(i, "-", j, "=", i - j, ";%03d" % r)
- if j > 0 and i % j == 0 and i / j in valid_numbers:
- r = i * 100 + j * 10 + (i / j)
- result.add(r)
- print(i, "/", j, "=", int(i / j), ";%03d" % r)
- if i * j in valid_numbers:
- r = i * 100 + j * 10 + (i * j)
- result.add(r)
- print(i, "*", j, "=", i * j, ";%03d" % r)
- result = list(result)
- result.sort()
- num_number_combinations = len(result)
- print("Letter Combinations:", num_letter_combinations)
- print("Number Combinations:", num_number_combinations)
- print("Total Combinations:", num_letter_combinations * num_number_combinations)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement