From a1bf11a5edcbe706e222f3c8a30764598f58c872 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Engl=C3=B6f=20Ytterstr=C3=B6m?= Date: Mon, 11 Dec 2023 00:44:19 +0100 Subject: [PATCH] Fix flake8 errors for 2023:1-10 --- 2023-python/README.md | 4 ++++ 2023-python/aoc.py | 4 ++-- 2023-python/output/day_01.py | 2 +- 2023-python/output/day_02.py | 2 +- 2023-python/output/day_03.py | 2 +- 2023-python/output/day_04.py | 4 ++-- 2023-python/output/day_05.py | 4 +--- 2023-python/output/day_06.py | 2 +- 2023-python/output/day_07.py | 2 +- 2023-python/output/day_08.py | 2 +- 2023-python/output/day_09.py | 2 +- 2023-python/output/day_10.py | 9 ++++----- 12 files changed, 20 insertions(+), 19 deletions(-) diff --git a/2023-python/README.md b/2023-python/README.md index 2edcd21..249aff0 100644 --- a/2023-python/README.md +++ b/2023-python/README.md @@ -36,3 +36,7 @@ Execute separate puzzle on file save (replace `XX` with the puzzle number): (requires `entr` and `wl-paste`, Mac users can instead use `pbpaste`. If you prefer X at Linux, use `xclip -selection clipboard -o`). + +To lint files: + + ls output/*.py | entr -r -c flake8 output --ignore=E741,E501,E203 diff --git a/2023-python/aoc.py b/2023-python/aoc.py index 2f10cf8..090129d 100644 --- a/2023-python/aoc.py +++ b/2023-python/aoc.py @@ -56,8 +56,8 @@ if __name__ == "__main__": # import sys; inp = sys.stdin.read().strip() # uncomment to use AoC provided puzzle input - # with open(f"./input/{padded_no}.txt", "r") as f: - # inp = f.read() + # with open("./input/{padded_no}.txt", "r") as f: + # inp = f.read().strip() # uncomment to do initial data processing shared by part 1-2 inp = solve(inp) diff --git a/2023-python/output/day_01.py b/2023-python/output/day_01.py index f1f6483..f2eecfb 100644 --- a/2023-python/output/day_01.py +++ b/2023-python/output/day_01.py @@ -41,7 +41,7 @@ def part_2(data): if __name__ == "__main__": - with open(f"./input/01.txt", "r") as f: + with open("./input/01.txt", "r") as f: inp = f.read().strip() a = part_1(inp) diff --git a/2023-python/output/day_02.py b/2023-python/output/day_02.py index d198b2e..f5ac032 100644 --- a/2023-python/output/day_02.py +++ b/2023-python/output/day_02.py @@ -39,7 +39,7 @@ def part_2(data): if __name__ == "__main__": - with open(f"./input/02.txt", "r") as f: + with open("./input/02.txt", "r") as f: inp = f.read().strip() a = part_1(inp) diff --git a/2023-python/output/day_03.py b/2023-python/output/day_03.py index b04c037..19df9ae 100644 --- a/2023-python/output/day_03.py +++ b/2023-python/output/day_03.py @@ -56,7 +56,7 @@ def presolve(data): if __name__ == "__main__": - with open(f"./input/03.txt", "r") as f: + with open("./input/03.txt", "r") as f: inp = f.read().strip() parsed = presolve(inp) diff --git a/2023-python/output/day_04.py b/2023-python/output/day_04.py index 2fe7400..66c9f8c 100644 --- a/2023-python/output/day_04.py +++ b/2023-python/output/day_04.py @@ -27,7 +27,7 @@ def presolve(data): b = set(re.findall(r"\d+", b)) ab = len(a & b) if ab > 0: - scores.append(2**(ab - 1)) + scores.append(2 ** (ab - 1)) count[cid] += 1 for i in range(cid + 1, cid + ab + 1): count[i] += count[cid] @@ -35,7 +35,7 @@ def presolve(data): if __name__ == "__main__": - with open(f"./input/04.txt", "r") as f: + with open("./input/04.txt", "r") as f: inp = f.read().strip() inp = presolve(inp) diff --git a/2023-python/output/day_05.py b/2023-python/output/day_05.py index bbce1d7..4147802 100644 --- a/2023-python/output/day_05.py +++ b/2023-python/output/day_05.py @@ -1,7 +1,5 @@ import re -from itertools import repeat from math import inf -from multiprocessing import Pool, freeze_support from output import answer n = 5 @@ -63,7 +61,7 @@ def _nearest(start, processes, reverse=False): if __name__ == "__main__": - with open(f"./input/05.txt", "r") as f: + with open("./input/05.txt", "r") as f: inp = f.read().strip() inp = presolve(inp) diff --git a/2023-python/output/day_06.py b/2023-python/output/day_06.py index 0212a16..1f9bfa7 100644 --- a/2023-python/output/day_06.py +++ b/2023-python/output/day_06.py @@ -35,7 +35,7 @@ def presolve(data): if __name__ == "__main__": - with open(f"./input/06.txt", "r") as f: + with open("./input/06.txt", "r") as f: inp = f.read().strip() inp = presolve(inp) diff --git a/2023-python/output/day_07.py b/2023-python/output/day_07.py index be8f659..a583564 100644 --- a/2023-python/output/day_07.py +++ b/2023-python/output/day_07.py @@ -84,7 +84,7 @@ if __name__ == "__main__": doctest.testmod() - with open(f"./input/07.txt", "r") as f: + with open("./input/07.txt", "r") as f: inp = f.read().strip() a = part_1(inp) diff --git a/2023-python/output/day_08.py b/2023-python/output/day_08.py index 2bc692c..b2f397b 100644 --- a/2023-python/output/day_08.py +++ b/2023-python/output/day_08.py @@ -49,7 +49,7 @@ def presolve(data): if __name__ == "__main__": - with open(f"./input/08.txt", "r") as f: + with open("./input/08.txt", "r") as f: inp = f.read().strip() inp = presolve(inp) diff --git a/2023-python/output/day_09.py b/2023-python/output/day_09.py index 0f8d9ab..423047f 100644 --- a/2023-python/output/day_09.py +++ b/2023-python/output/day_09.py @@ -30,7 +30,7 @@ def _solve(lines): if __name__ == "__main__": - with open(f"./input/09.txt", "r") as f: + with open("./input/09.txt", "r") as f: inp = f.read().strip() a = part_1(inp) diff --git a/2023-python/output/day_10.py b/2023-python/output/day_10.py index db34b6c..7420d86 100644 --- a/2023-python/output/day_10.py +++ b/2023-python/output/day_10.py @@ -1,5 +1,4 @@ -import re -from collections import Counter, defaultdict, deque +from collections import deque from output import answer n = 10 @@ -26,12 +25,12 @@ A = { } -@answer(1, "Answer is {}") +@answer(1, "Farthest away pipe is at {}") def part_1(presolved): return presolved[0] -@answer(2, "Actually, answer is {}") +@answer(2, "{} spots are encapsulated by pipes") def part_2(presolved): return presolved[1] @@ -83,7 +82,7 @@ def presolve(data): if __name__ == "__main__": - with open(f"./input/10.txt", "r") as f: + with open("./input/10.txt", "r") as f: inp = f.read() inp = presolve(inp)