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