diff --git a/day_1/main.py b/day_1/main.py new file mode 100644 index 0000000..8176639 --- /dev/null +++ b/day_1/main.py @@ -0,0 +1,15 @@ + +with open('input') as f: + groups = [] + sum_ = 0 + for line in f: + line = line.strip() + if line == '': + if sum_ > 0: + groups.append(sum_) + sum_ = 0 + else: + sum_ += int(line) + + print(max(groups)) + diff --git a/day_1/main2 b/day_1/main2 new file mode 100755 index 0000000..1343734 Binary files /dev/null and b/day_1/main2 differ diff --git a/day_1/main2.py b/day_1/main2.py new file mode 100644 index 0000000..19ba106 --- /dev/null +++ b/day_1/main2.py @@ -0,0 +1,22 @@ + +with open('input') as f: + groups = [] + sum_ = 0 + for line in f: + line = line.strip() + if line == '': + if sum_ > 0: + groups.append(sum_) + sum_ = 0 + else: + sum_ += int(line) + + a = max(groups) + groups.remove(max(groups)) + b = max(groups) + groups.remove(max(groups)) + c = max(groups) + groups.remove(max(groups)) + + print(a + b + c) +