Skip to content

Commit 3ded2ec

Browse files
committed
added 2016/day05
1 parent fdf9fdc commit 3ded2ec

File tree

4 files changed

+43
-1
lines changed

4 files changed

+43
-1
lines changed

2016/day05/answers.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1a3099aa
2+
694190cd

2016/day05/input.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uqwqemis

2016/day05/run.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#! /usr/bin/env python3
2+
3+
def load_data(filename):
4+
with open(filename, 'r') as f:
5+
line = f.readline().rstrip('\n')
6+
return line
7+
8+
# Part One
9+
10+
door_id = load_data('input.txt')
11+
12+
from hashlib import md5
13+
14+
index = 0
15+
result = ''
16+
17+
for _ in range(8):
18+
while not (hash := md5((door_id + str(index)).encode('ascii')).hexdigest()).startswith('00000'):
19+
index += 1
20+
index += 1
21+
result += hash[5]
22+
23+
print(result)
24+
25+
# Part Two
26+
27+
index = 0
28+
result = list('_' * 8)
29+
30+
while '_' in result:
31+
while not (hash := md5((door_id + str(index)).encode('ascii')).hexdigest()).startswith('00000'):
32+
index += 1
33+
index += 1
34+
i = int(hash[5], 16)
35+
if i >= len(result) or result[i] != '_':
36+
continue
37+
result[i] = hash[6]
38+
39+
print(''.join(result))

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
```
22
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
33
2015 ++ ++ ++ ++ ++ ++ ++ ++ ++ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +
4-
2016 ++ ++ ++ ++ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
4+
2016 ++ ++ ++ ++ ++ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
55
2017 ++ ++ ++ ++ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
66
2018 ++ ++ ++ ++ ++ ++ ++ ++ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +
77
2019 ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ -- ++ ++ -- +- ++ +- -

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy