From eaf873b458a74742ee14088e78d8b9dd6a68505a Mon Sep 17 00:00:00 2001 From: Andres Date: Wed, 11 Dec 2024 22:30:01 +0100 Subject: [PATCH] 2015 day 4 --- 2015/day-4/input.txt | 1 + 2015/day-4/part-1.py | 15 +++++++++++++++ 2015/day-4/part-2.py | 15 +++++++++++++++ 2015/day-4/test-input.txt | 1 + 4 files changed, 32 insertions(+) create mode 100644 2015/day-4/input.txt create mode 100644 2015/day-4/part-1.py create mode 100644 2015/day-4/part-2.py create mode 100644 2015/day-4/test-input.txt diff --git a/2015/day-4/input.txt b/2015/day-4/input.txt new file mode 100644 index 0000000..922d9e6 --- /dev/null +++ b/2015/day-4/input.txt @@ -0,0 +1 @@ +bgvyzdsv \ No newline at end of file diff --git a/2015/day-4/part-1.py b/2015/day-4/part-1.py new file mode 100644 index 0000000..ae2f5e5 --- /dev/null +++ b/2015/day-4/part-1.py @@ -0,0 +1,15 @@ +import os +import hashlib + +file_path = os.path.join(os.path.dirname(__file__), "./input.txt") +# file_path = os.path.join(os.path.dirname(__file__), "./test-input.txt") +input = open(file_path).read().strip() + + +number = 0 +while True: + result = hashlib.md5((input + str(number)).encode()).hexdigest() + if result.startswith("00000"): + print(number) + break + number += 1 diff --git a/2015/day-4/part-2.py b/2015/day-4/part-2.py new file mode 100644 index 0000000..7c4bfb0 --- /dev/null +++ b/2015/day-4/part-2.py @@ -0,0 +1,15 @@ +import os +import hashlib + +file_path = os.path.join(os.path.dirname(__file__), "./input.txt") +# file_path = os.path.join(os.path.dirname(__file__), "./test-input.txt") +input = open(file_path).read().strip() + + +number = 0 +while True: + result = hashlib.md5((input + str(number)).encode()).hexdigest() + if result.startswith("000000"): + print(number) + break + number += 1 diff --git a/2015/day-4/test-input.txt b/2015/day-4/test-input.txt new file mode 100644 index 0000000..d96dc95 --- /dev/null +++ b/2015/day-4/test-input.txt @@ -0,0 +1 @@ +abcdef \ No newline at end of file