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)