From 20392aaf5dfd68c3fc1533a484d0758a878769a3 Mon Sep 17 00:00:00 2001 From: Tristan Date: Fri, 30 Nov 2018 14:39:18 +0000 Subject: [PATCH] 2015 day 4 complete --- 2015/4/part1.py | 14 ++++++++++++++ README.md | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 2015/4/part1.py diff --git a/2015/4/part1.py b/2015/4/part1.py new file mode 100644 index 0000000..59ed54e --- /dev/null +++ b/2015/4/part1.py @@ -0,0 +1,14 @@ +input = "ckczppom" + +import hashlib +num = 6 +i = 0 +while True: + i += 1 + m = hashlib.md5() + m.update(str(input+str(i)).encode()) + print(m.hexdigest()) + if m.hexdigest()[0:num] == "0"*num: + print(i) + break + diff --git a/README.md b/README.md index 7c9c562..b8b68d0 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ It's a fun challenge from [here](https://adventofcode.com). * [1](https://adventofcode.com/2015/day/1) * * * [2](https://adventofcode.com/2015/day/2) * * * [3](https://adventofcode.com/2015/day/3) * * - * [4](https://adventofcode.com/2015/day/4) + * [4](https://adventofcode.com/2015/day/4) * * * [2016](https://adventofcode.com/2016) * [2017](https://adventofcode.com/2017) * [2018](https://adventofcode.com/2018)