Compare commits
3 Commits
bc95943995
...
2a7e04ef2b
Author | SHA1 | Date | |
---|---|---|---|
2a7e04ef2b | |||
ebd1566973 | |||
31b146192d |
1
2015/day4/input
Normal file
1
2015/day4/input
Normal file
@ -0,0 +1 @@
|
|||||||
|
bgvyzdsv
|
31
2015/day4/part1.py
Normal file
31
2015/day4/part1.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/python3
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from pprint import pprint
|
||||||
|
import hashlib
|
||||||
|
|
||||||
|
input_f = sys.argv[1]
|
||||||
|
|
||||||
|
result = 0
|
||||||
|
count = 0
|
||||||
|
found = False
|
||||||
|
with open(input_f) as file:
|
||||||
|
for line in file:
|
||||||
|
tmp = line.rstrip()
|
||||||
|
while found == False:
|
||||||
|
m = hashlib.md5()
|
||||||
|
text = tmp + str(count)
|
||||||
|
#print(text)
|
||||||
|
m.update(text.encode('UTF-8'))
|
||||||
|
nr = m.hexdigest()
|
||||||
|
#print(nr)
|
||||||
|
|
||||||
|
if nr[0:5] == '00000':
|
||||||
|
print(count)
|
||||||
|
print(text)
|
||||||
|
print(nr)
|
||||||
|
found = True
|
||||||
|
else:
|
||||||
|
count += 1
|
||||||
|
#print(nr[ 0 : 5 ])
|
||||||
|
found = False
|
31
2015/day4/part2.py
Normal file
31
2015/day4/part2.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/python3
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from pprint import pprint
|
||||||
|
import hashlib
|
||||||
|
|
||||||
|
input_f = sys.argv[1]
|
||||||
|
|
||||||
|
result = 0
|
||||||
|
count = 0
|
||||||
|
found = False
|
||||||
|
with open(input_f) as file:
|
||||||
|
for line in file:
|
||||||
|
tmp = line.rstrip()
|
||||||
|
while found == False:
|
||||||
|
m = hashlib.md5()
|
||||||
|
text = tmp + str(count)
|
||||||
|
#print(text)
|
||||||
|
m.update(text.encode('UTF-8'))
|
||||||
|
nr = m.hexdigest()
|
||||||
|
#print(nr)
|
||||||
|
|
||||||
|
if nr[0:6] == '000000':
|
||||||
|
print(count)
|
||||||
|
print(text)
|
||||||
|
print(nr)
|
||||||
|
found = True
|
||||||
|
else:
|
||||||
|
count += 1
|
||||||
|
#print(nr[ 0 : 5 ])
|
||||||
|
found = False
|
2
2015/day4/test
Normal file
2
2015/day4/test
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
abcdef
|
||||||
|
pqrstuv
|
Loading…
Reference in New Issue
Block a user