Fix linting.

This commit is contained in:
Mikael CAPELLE
2024-12-03 14:11:29 +01:00
parent 5c43eb2c73
commit b32d46b641
49 changed files with 1160 additions and 353 deletions

View File

@@ -1,6 +1,4 @@
import sys
from collections import defaultdict
from dataclasses import dataclass
lines = sys.stdin.read().splitlines()

View File

@@ -1,6 +1,4 @@
import sys
from collections import defaultdict
from dataclasses import dataclass
lines = sys.stdin.read().splitlines()

View File

@@ -1,6 +1,4 @@
import sys
from collections import defaultdict
from dataclasses import dataclass
lines = sys.stdin.read().splitlines()

View File

@@ -1,6 +1,4 @@
import sys
from collections import defaultdict
from dataclasses import dataclass
lines = sys.stdin.read().splitlines()

View File

@@ -1,6 +1,4 @@
import sys
from collections import defaultdict
from dataclasses import dataclass
lines = sys.stdin.read().splitlines()

View File

@@ -1,6 +1,4 @@
import sys
from collections import defaultdict
from dataclasses import dataclass
lines = sys.stdin.read().splitlines()

View File

@@ -1,6 +1,4 @@
import sys
from collections import defaultdict
from dataclasses import dataclass
lines = sys.stdin.read().splitlines()

View File

@@ -1,6 +1,4 @@
import sys
from collections import defaultdict
from dataclasses import dataclass
lines = sys.stdin.read().splitlines()

View File

@@ -1,6 +1,4 @@
import sys
from collections import defaultdict
from dataclasses import dataclass
lines = sys.stdin.read().splitlines()

View File

@@ -1,6 +1,4 @@
import sys
from collections import defaultdict
from dataclasses import dataclass
lines = sys.stdin.read().splitlines()

View File

@@ -1,12 +1,13 @@
import sys
from math import prod
from typing import Literal, cast
from typing import Literal, TypeAlias, cast
lines = sys.stdin.read().splitlines()
commands = [
(cast(Literal["forward", "up", "down"], (p := line.split())[0]), int(p[1]))
for line in lines
Command: TypeAlias = Literal["forward", "up", "down"]
commands: list[tuple[Command, int]] = [
(cast(Command, (p := line.split())[0]), int(p[1])) for line in lines
]

View File

@@ -1,6 +1,4 @@
import sys
from collections import defaultdict
from dataclasses import dataclass
lines = sys.stdin.read().splitlines()

View File

@@ -1,6 +1,4 @@
import sys
from collections import defaultdict
from dataclasses import dataclass
lines = sys.stdin.read().splitlines()

View File

@@ -1,6 +1,4 @@
import sys
from collections import defaultdict
from dataclasses import dataclass
lines = sys.stdin.read().splitlines()

View File

@@ -1,6 +1,4 @@
import sys
from collections import defaultdict
from dataclasses import dataclass
lines = sys.stdin.read().splitlines()

View File

@@ -1,6 +1,4 @@
import sys
from collections import defaultdict
from dataclasses import dataclass
lines = sys.stdin.read().splitlines()

View File

@@ -1,6 +1,4 @@
import sys
from collections import defaultdict
from dataclasses import dataclass
lines = sys.stdin.read().splitlines()

View File

@@ -1,21 +1,19 @@
import sys
import numpy as np
positions = [int(c) for c in sys.stdin.read().strip().split(",")]
positions = np.asarray([int(c) for c in sys.stdin.read().strip().split(",")])
min_position, max_position = positions.min(), positions.max()
min_position, max_position = min(positions), max(positions)
# part 1
answer_1 = min(
np.sum(np.abs(positions - position))
sum(abs(p - position) for p in positions)
for position in range(min_position, max_position + 1)
)
print(f"answer 1 is {answer_1}")
# part 2
answer_2 = min(
np.sum(abs(positions - position) * (abs(positions - position) + 1) // 2)
sum(abs(p - position) * (abs(p - position) + 1) // 2 for p in positions)
for position in range(min_position, max_position + 1)
)
print(f"answer 2 is {answer_2}")