Skip to content

Instantly share code, notes, and snippets.

@Getup1
Created November 20, 2020 22:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Getup1/dca1c229ddac9e167b194008943ade60 to your computer and use it in GitHub Desktop.
Save Getup1/dca1c229ddac9e167b194008943ade60 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
def matcher(pattern):
def sieve(string):
if len(string) != len(pattern):
return False
matched = True
for a, b in zip(pattern, string):
if a != '*' and a != b:
matched = False
break
return matched
return sieve
p1 = ["the", "if", "of", "as", "in", "a", "you", "from", "to", "an", "too", "little", "snow", "dead", "drunk", "rosebud", "duck", "al", "le"]
p2 = ["diamond", "beer", "mushroom", "assistant", "clown", "captain", "twinkie", "security", "nuke", "small", "big", "escape", "yellow", "gloves", "monkey", "engine", "nuclear", "ai"]
p3 = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]
allCombs = [
q1 + q2 + q3
for q1 in p1
for q2 in p2
for q3 in p3
]
while len(allCombs) > 1:
pattern = input("Input pattern: ")
allCombs = list(filter(matcher(pattern), allCombs))
print(f"Matching passwords: {len(allCombs)}")
print(allCombs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment