Created
April 27, 2022 05:31
-
-
Save akashlevy/d293008ae3a399bead75e7dbd479fe1d to your computer and use it in GitHub Desktop.
Hexadecimal Words
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
import re, string | |
minlen = 3 | |
subs = [ | |
#('for', '4'), | |
#('four', '4'), | |
#('to', '2'), | |
#('ate', '8'), | |
#('ten', '10'), | |
#('g', '6'), | |
('l', '1'), | |
('o', '0'), | |
('s', '5'), | |
#('t', '7') | |
] | |
reHexWord = re.compile("[a-f0-9]*") | |
fWords = open('words.txt', 'r') | |
for w in fWords.xreadlines(): | |
w = w.strip() | |
for old, new in subs: | |
w = string.replace(w, old, new) | |
if len(w) >= minlen: | |
match = reHexWord.search(w) | |
if match and match.group() == w: | |
print(w) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment