Skip to content

Commit

Permalink
Sort imports
Browse files Browse the repository at this point in the history
  • Loading branch information
agagniere committed Dec 19, 2023
1 parent dc81db3 commit ced2be5
Show file tree
Hide file tree
Showing 32 changed files with 70 additions and 27 deletions.
1 change: 1 addition & 0 deletions 2023/01/first.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from utils import lines


def extractValue(line):
digits = list(filter(str.isdigit, line))
return int(digits[0] + digits[-1])
Expand Down
4 changes: 3 additions & 1 deletion 2023/02/second.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from utils import lines
from collections import defaultdict
from math import prod

from utils import lines


def power(line):
game, draws = line.split(': ')
maximum = defaultdict(int)
Expand Down
2 changes: 1 addition & 1 deletion 2023/03/first.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from utils import lines, Point
from utils import Point, lines

board = list(lines())

Expand Down
3 changes: 2 additions & 1 deletion 2023/03/second.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from utils import lines, Point
from collections import defaultdict
from math import prod

from utils import Point, lines

board = list(lines())
gears = defaultdict(list)
adjacent = dict()
Expand Down
1 change: 1 addition & 0 deletions 2023/04/first.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def score(line: str) -> int:

from unittest import TestCase


class TestDay4_1(TestCase):

def test_parsing(self):
Expand Down
5 changes: 4 additions & 1 deletion 2023/04/second.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from utils import lines
from collections import defaultdict

from utils import lines


def toIntegerSet(string: str) -> set[int]:
"Converts ' 1 21 53 59 44 ' to {1, 21, 53, 59, 44}"
return set(int(x) for x in string.split(' ') if x)
Expand All @@ -25,6 +27,7 @@ def countPerCard(lines) -> dict[int, int]:

from unittest import TestCase


class TestDay4_2(TestCase):

def test_parsing(self):
Expand Down
4 changes: 3 additions & 1 deletion 2023/05/first.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from utils import lines, debug
from collections import defaultdict

from utils import debug, lines


def parser(lines):
"From an iterable of strings, iterate over the maps described"
source = None
Expand Down
5 changes: 3 additions & 2 deletions 2023/05/second.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from utils import lines, debug
from collections import defaultdict
from more_itertools import grouper

from first import parser
from more_itertools import grouper
from utils import debug, lines


class Range:
def __init__(self, start, one_past_end):
Expand Down
1 change: 1 addition & 0 deletions 2023/05/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys


def lines():
while True:
try:
Expand Down
1 change: 1 addition & 0 deletions 2023/06/first.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def part1(time_limits: list[int], records: list[int]) -> int:

from unittest import TestCase


class TestDay6_1(TestCase):

def test_parse(self):
Expand Down
3 changes: 2 additions & 1 deletion 2023/06/second.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from first import simulate, number_of_ways_to_win
from first import number_of_ways_to_win, simulate


def parse(line: str) -> list[str]:
Expand All @@ -13,6 +13,7 @@ def parse(line: str) -> list[str]:

from unittest import TestCase


class TestDay6_2(TestCase):

def test_parse(self):
Expand Down
4 changes: 3 additions & 1 deletion 2023/07/first.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from utils import lines
from collections import Counter, namedtuple

from utils import lines

Hand = namedtuple('Hand', ['type', 'card_values', 'bid'])

class CamelCards:
Expand Down Expand Up @@ -34,6 +35,7 @@ def total_winnings(cls, lines) -> int:

from unittest import TestCase


class TestDay7_1(TestCase):

def test_hand_type(self):
Expand Down
6 changes: 4 additions & 2 deletions 2023/07/second.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from utils import lines
from collections import Counter

from first import Hand, CamelCards
from first import CamelCards, Hand
from utils import lines


class CamelCardsVariant(CamelCards):
CARDS = "J23456789TQKA"
Expand All @@ -26,6 +27,7 @@ def hand_type(cls, hand: str) -> tuple:

from unittest import TestCase


class TestDay7_2(TestCase):

def test_hand_type(self):
Expand Down
1 change: 1 addition & 0 deletions 2023/08/first.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def navigate(network: dict, instructions: str, start: str = 'AAA') -> int:

from unittest import TestCase


class TestDay8_1(TestCase):
sample = {
'AAA = (BBB, BBB)': ('AAA', 'BBB', 'BBB'),
Expand Down
1 change: 1 addition & 0 deletions 2023/08/second.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def ghost_solve(network: map, instructions: str) -> int:

from unittest import TestCase


class TestDay8_2(TestCase):
def test_solve(self):
sample = {
Expand Down
2 changes: 2 additions & 0 deletions 2023/09/first.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from utils import lines


def parse(line: str) -> list[int]:
return list(map(int, line.split()))

Expand All @@ -19,6 +20,7 @@ def part1(lines) -> int:

from unittest import TestCase


class TestDay9_1(TestCase):

sample = {
Expand Down
4 changes: 3 additions & 1 deletion 2023/09/second.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from utils import lines
from first import parse
from utils import lines


def extrapolate(sequence: list[int]) -> int:
diff = [b - a for a, b in zip(sequence, sequence[1:])]
Expand All @@ -17,6 +18,7 @@ def part2(lines) -> int:

from unittest import TestCase


class TestDay9_2(TestCase):

sample = {
Expand Down
1 change: 1 addition & 0 deletions 2023/10/first.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def visualize(lines):

from unittest import TestCase


class TestDay10_1(TestCase):

samples = [
Expand Down
2 changes: 1 addition & 1 deletion 2023/10/second.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from first import DISPLAY, TILES, find_loop, parse
from utils import Point, lines


# Constants

INFER_TILE = {tuple(sorted(pair)): c for c, pair in TILES.items()}
Expand Down Expand Up @@ -47,6 +46,7 @@ def part2(lines, visualize = False):

from unittest import TestCase


class TestDay10_2(TestCase):

samples = [
Expand Down
1 change: 1 addition & 0 deletions 2023/11/second.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def part2(lines: list[str], factor: int = 1000000) -> int:

from first import sample


class TestDay11_2(TestCase):

def test_part1(self):
Expand Down
3 changes: 2 additions & 1 deletion 2023/13/first.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from utils import lines, split, Point
from utils import Point, lines, split


class Part1:

Expand Down
6 changes: 4 additions & 2 deletions 2023/13/second.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from utils import lines, split, Point

from first import Part1
from utils import Point, lines, split


class Part2(Part1):

Expand All @@ -21,8 +21,10 @@ def find_reflection(zone: list[str], flipped: list[tuple[str]]):
# ------------------------------

from unittest import TestCase

from first import sample


class TestDay13_1(TestCase):

expected_reflections = [(0, 3), (0, 1)]
Expand Down
4 changes: 3 additions & 1 deletion 2023/14/first.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from utils import lines, Point
from collections import Counter, defaultdict

from utils import Point, lines


def part1(lines):
previous = defaultdict(int)
result = []
Expand Down
4 changes: 3 additions & 1 deletion 2023/14/second.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from utils import lines, Point
from collections import Counter
from enum import IntEnum, auto
from functools import cache

from utils import Point, lines


@cache
def tilt_left(row: str) -> str:
previous = 0
Expand Down
1 change: 1 addition & 0 deletions 2023/15/first.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from functools import cache


@cache
def santa_hash(string: str) -> int:
result = 0
Expand Down
4 changes: 3 additions & 1 deletion 2023/15/second.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from collections import OrderedDict, defaultdict

from first import santa_hash
from collections import defaultdict, OrderedDict


def execute(instructions: list[str]):
Expand All @@ -25,6 +26,7 @@ def execute(instructions: list[str]):

from first import sample


class TestDay15_1(TestCase):

def test_execute(self):
Expand Down
4 changes: 3 additions & 1 deletion 2023/16/first.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from utils import lines, Point
from collections import defaultdict

from utils import Point, lines


def count_energy(board: list[str], start: Point, direction: (int, int)) -> int:
seen = defaultdict(set)

Expand Down
3 changes: 2 additions & 1 deletion 2023/16/second.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from utils import lines, Point
from collections import defaultdict

from first import count_energy
from utils import Point, lines


def part2(lines: list[str]) -> int:
results = []
Expand Down
5 changes: 3 additions & 2 deletions 2023/17/first.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from utils import lines, Point
from collections import Counter, defaultdict, deque, namedtuple
from heapq import heappush, heappop
from heapq import heappop, heappush

from utils import Point, lines

# 976
# 964
Expand Down
5 changes: 3 additions & 2 deletions 2023/17/second.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from utils import lines, Point
from collections import Counter, defaultdict, deque, namedtuple
from heapq import heappush, heappop
from heapq import heappop, heappush

from utils import Point, lines

# 976
# 964
Expand Down
3 changes: 2 additions & 1 deletion 2023/18/first.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from utils import lines, Point
from collections import deque

from utils import Point, lines

MOVE = {
'R': (1, 0),
'L': (-1, 0),
Expand Down
3 changes: 2 additions & 1 deletion 2023/18/second.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from utils import lines, Point
from collections import deque

from utils import Point, lines

MOVE = {
'R': Point(1, 0),
'L': Point(-1, 0),
Expand Down

0 comments on commit ced2be5

Please sign in to comment.