Last active
February 4, 2020 17:38
-
-
Save cetaSYN/69dbe14b7d060448e1cc8a962b799ad8 to your computer and use it in GitHub Desktop.
SANS Holiday Hack 2019 Dormitory Keypad Solver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SANS Holiday Hack 2019 Dormitory Keypad Solver | |
from itertools import product | |
# https://stackoverflow.com/questions/46841968/fastest-way-of-testing-if-a-number-is-prime-with-python | |
def is_prime(n): | |
if n & 1 == 0: | |
return False | |
d= 3 | |
while d * d <= n: | |
if n % d == 0: | |
return False | |
d= d + 2 | |
return True | |
digits = [1, 3, 7] | |
for opt in product(digits, repeat=4): | |
if set(digits).issubset(opt): # Must contain all digits at least once | |
opt = int(''.join(str(c) for c in opt)) | |
if is_prime(opt): | |
print(opt) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output:
Solution was
7331
AKA 1337 backwards, because of course it is.