From 31b146192d5a95a30acef854c8e1e9561673ed95 Mon Sep 17 00:00:00 2001 From: FrederikBaerentsen Date: Mon, 4 Dec 2023 18:20:16 +0100 Subject: [PATCH] Finished 2015-12-04 part 1 --- 2015/day4/input | 1 + 2015/day4/part1.py | 31 +++++++++++++++++++++++++++++++ 2015/day4/test | 2 ++ 3 files changed, 34 insertions(+) create mode 100644 2015/day4/input create mode 100644 2015/day4/part1.py create mode 100644 2015/day4/test diff --git a/2015/day4/input b/2015/day4/input new file mode 100644 index 0000000..bf3e46f --- /dev/null +++ b/2015/day4/input @@ -0,0 +1 @@ +bgvyzdsv diff --git a/2015/day4/part1.py b/2015/day4/part1.py new file mode 100644 index 0000000..d227e50 --- /dev/null +++ b/2015/day4/part1.py @@ -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 diff --git a/2015/day4/test b/2015/day4/test new file mode 100644 index 0000000..e083919 --- /dev/null +++ b/2015/day4/test @@ -0,0 +1,2 @@ +abcdef +pqrstuv