From 8ec6322f5139bb09966f84390b2c6d2cf1dd0ce1 Mon Sep 17 00:00:00 2001 From: dusk Date: Thu, 24 Jul 2025 23:07:02 +0000 Subject: [PATCH] completed 2017-02.2 --- 2017/02/2checksum.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 2017/02/2checksum.py diff --git a/2017/02/2checksum.py b/2017/02/2checksum.py new file mode 100755 index 0000000..ad7df20 --- /dev/null +++ b/2017/02/2checksum.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 + +if __name__ == '__main__': + total = 0 + with open("input", "r", encoding="utf-8") as sheet: + remainder = [] + for line in sheet: + values = list(map(int, line.split())) + values.sort() + result = "" + i = 1 + while i < len(values) and result == "": + j = 0 + while j >= 0 and j < i and result == "": + remainder = values[i] % values[j] + if remainder == 0: + result = int(values[i] / values[j]) + j += 1 + i += 1 + total += result + print(total)