Initial commit
This commit is contained in:
commit
97a4330bc0
110 changed files with 7006 additions and 0 deletions
5
2023/1/obfuscated.py
Normal file
5
2023/1/obfuscated.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
import re
|
||||
d="zero|one|two|three|four|five|six|seven|eight|nine|\\d)"
|
||||
def f(l,p):
|
||||
m=re.search(p,l)[1];return str(d.split("|").index(m)) if m in d else m
|
||||
print(sum(map(lambda l:int(f(l,f"({d}.*")+f(l,".*("+d)),open(0).readlines())))
|
30
2023/1/script.py
Normal file
30
2023/1/script.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import re
|
||||
|
||||
digits = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]
|
||||
group = "|".join(digits + ["[0-9]"])
|
||||
|
||||
tot = 0
|
||||
with open("lines.txt") as lines:
|
||||
for line in lines.readlines():
|
||||
print()
|
||||
line = line.rstrip()
|
||||
print(line)
|
||||
last = re.search(rf"^.*({group})", line)
|
||||
first = re.search(rf"({group}).*$", line)
|
||||
print(first, last)
|
||||
f = first[1]
|
||||
l = last[1]
|
||||
print(f, l)
|
||||
if f in digits:
|
||||
f = str(digits.index(f))
|
||||
if l in digits:
|
||||
l = str(digits.index(l))
|
||||
print(f, l)
|
||||
numb = int(f + l)
|
||||
tot += numb
|
||||
print(numb)
|
||||
print()
|
||||
|
||||
print(tot)
|
Loading…
Add table
Add a link
Reference in a new issue