Skip to content

Commit

Permalink
Merge pull request #94 from wimglenn/more-stdlib
Browse files Browse the repository at this point in the history
use stuff which wasnt avail in earlier python versions
  • Loading branch information
wimglenn authored Dec 10, 2023
2 parents b89be59 + fdcfb09 commit c1fe58c
Show file tree
Hide file tree
Showing 151 changed files with 293 additions and 135 deletions.
1 change: 1 addition & 0 deletions aoc_wim/aoc2015/q04.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
https://adventofcode.com/2015/day/4
"""
from _md5 import md5

from aocd import data


Expand Down
2 changes: 1 addition & 1 deletion aoc_wim/aoc2015/q07.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import operator
import re

from aocd import data
import numpy as np
from aocd import data


# TODO: change to use topological sort
Expand Down
1 change: 1 addition & 0 deletions aoc_wim/aoc2015/q17.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
https://adventofcode.com/2015/day/17
"""
from aocd import data

from aoc_wim.stuff import subset_sum

vals = [int(n) for n in data.splitlines()]
Expand Down
1 change: 1 addition & 0 deletions aoc_wim/aoc2015/q22.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""
from aocd import data
from fields import Fields

from aoc_wim.search import AStar


Expand Down
4 changes: 2 additions & 2 deletions aoc_wim/aoc2016/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import logging
from multiprocessing import current_process
import re
from _md5 import md5
from functools import partial
import re
from multiprocessing import current_process


log = logging.getLogger(__name__)
Expand Down
1 change: 1 addition & 0 deletions aoc_wim/aoc2016/q01.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
https://adventofcode.com/2016/day/1
"""
from aocd import data

from aoc_wim.zgrid import manhattan_distance


Expand Down
1 change: 1 addition & 0 deletions aoc_wim/aoc2016/q02.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
https://adventofcode.com/2016/day/2
"""
from aocd import data

from aoc_wim.zgrid import ZGrid


Expand Down
6 changes: 4 additions & 2 deletions aoc_wim/aoc2016/q05.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
--- Day 5: How About a Nice Game of Chess? ---
https://adventofcode.com/2016/day/5
"""
from aocd import data
import os
from collections import deque
from concurrent.futures import ProcessPoolExecutor
from aoc_wim.aoc2016 import md5_miner_q05
from itertools import count

from aocd import data

from aoc_wim.aoc2016 import md5_miner_q05


def main():
code1 = []
Expand Down
1 change: 1 addition & 0 deletions aoc_wim/aoc2016/q05_single_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
https://adventofcode.com/2016/day/5
"""
from _md5 import md5

from aocd import data


Expand Down
1 change: 1 addition & 0 deletions aoc_wim/aoc2016/q06.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
https://adventofcode.com/2016/day/6
"""
from collections import Counter

from aocd import data

counters = [Counter(x) for x in zip(*data.splitlines())]
Expand Down
1 change: 1 addition & 0 deletions aoc_wim/aoc2016/q08.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""
import numpy as np
from aocd import data

from aoc_wim.ocr import AOCR


Expand Down
4 changes: 2 additions & 2 deletions aoc_wim/aoc2016/q09.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
--- Day 9: Explosives in Cyberspace ---
https://adventofcode.com/2016/day/9
"""
from collections import deque
import re
import logging
import re
from collections import deque

from aocd import data

Expand Down
1 change: 1 addition & 0 deletions aoc_wim/aoc2016/q10.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
https://adventofcode.com/2016/day/10
"""
from math import prod

from aocd import data
from parse import parse

Expand Down
1 change: 1 addition & 0 deletions aoc_wim/aoc2016/q11.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from itertools import product

from aocd import data

from aoc_wim.search import AStar


Expand Down
1 change: 1 addition & 0 deletions aoc_wim/aoc2016/q12.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
https://adventofcode.com/2016/day/12
"""
from aocd import data

from aoc_wim.aoc2016 import AssembunnyComputer


Expand Down
6 changes: 4 additions & 2 deletions aoc_wim/aoc2016/q13.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
--- Day 13: A Maze of Twisty Little Cubicles ---
https://adventofcode.com/2016/day/13
"""
from aoc_wim.zgrid import ZGrid
from aocd import data
from functools import partial

from aocd import data

from aoc_wim.zgrid import ZGrid


def wall(z, fav_number):
if z.real < 0 or z.imag < 0:
Expand Down
6 changes: 4 additions & 2 deletions aoc_wim/aoc2016/q14.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
import re
from collections import defaultdict
from collections import deque
from concurrent.futures import ProcessPoolExecutor
from itertools import count

from aocd import data

from aoc_wim.aoc2016 import md5_miner_q14a
from aoc_wim.aoc2016 import md5_miner_q14b
from concurrent.futures import ProcessPoolExecutor
from itertools import count


def search(data, stretch):
Expand Down
3 changes: 2 additions & 1 deletion aoc_wim/aoc2016/q14_single_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
https://adventofcode.com/2016/day/14
"""
import re
from _md5 import md5
from collections import defaultdict

from aocd import data
from _md5 import md5


def search(data, stretch):
Expand Down
3 changes: 2 additions & 1 deletion aoc_wim/aoc2016/q17.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
--- Day 17: Two Steps Forward ---
https://adventofcode.com/2016/day/17
"""
from collections import deque
from _md5 import md5
from collections import deque

from aocd import data


Expand Down
1 change: 1 addition & 0 deletions aoc_wim/aoc2016/q23.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
https://adventofcode.com/2016/day/23
"""
from aocd import data

from aoc_wim.aoc2016 import AssembunnyComputer


Expand Down
4 changes: 3 additions & 1 deletion aoc_wim/aoc2016/q24.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
--- Day 24: Air Duct Spelunking ---
https://adventofcode.com/2016/day/24
"""
from aoc_wim.zgrid import ZGrid
from itertools import combinations
from itertools import permutations

import networkx as nx
from aocd import data

from aoc_wim.zgrid import ZGrid

grid = ZGrid(data, on=".", off="#")
graph = grid.graph(extra="0123456789")
distances = {}
Expand Down
1 change: 1 addition & 0 deletions aoc_wim/aoc2016/q25.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
https://adventofcode.com/2016/day/25
"""
import re

from aocd import data

x, y = re.findall(r"\d+", data)[:2]
Expand Down
1 change: 1 addition & 0 deletions aoc_wim/aoc2017/q03.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
https://adventofcode.com/2017/day/3
"""
from aocd import data

from aoc_wim.zgrid import manhattan_distance


Expand Down
3 changes: 1 addition & 2 deletions aoc_wim/aoc2017/q07.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from collections import deque

from aocd import data
from wimpy import cached_property


class Node:
Expand All @@ -16,7 +15,7 @@ def __init__(self, name):
self.parent = None
self.children = []

@cached_property
@property
def rweight(self):
return self.weight + sum(x.rweight for x in self.children)

Expand Down
3 changes: 2 additions & 1 deletion aoc_wim/aoc2017/q11.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
--- Day 11: Hex Ed ---
https://adventofcode.com/2017/day/11
"""
from aoc_wim import zgrid
from aocd import data

from aoc_wim import zgrid

z = d = dmax = 0
grid = zgrid.ZGrid({z: 1})
for step in data.split(","):
Expand Down
4 changes: 3 additions & 1 deletion aoc_wim/aoc2017/q18.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
--- Day 18: Duet ---
https://adventofcode.com/2017/day/18
"""
from aocd import data
from collections import deque

from aocd import data

from aoc_wim.aoc2017 import Comp

# import logging; logging.basicConfig(format="%(message)s", level=logging.DEBUG)
Expand Down
1 change: 1 addition & 0 deletions aoc_wim/aoc2017/q19.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
https://adventofcode.com/2017/day/19
"""
from aocd import data

from aoc_wim.zgrid import ZGrid


Expand Down
4 changes: 2 additions & 2 deletions aoc_wim/aoc2017/q20.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
https://adventofcode.com/2017/day/20
"""
from collections import defaultdict
from itertools import batched

from aocd import data
from parse import parse
from wimpy import chunks


def key(p):
return [abs(x) + abs(y) + abs(z) for x, y, z in chunks(reversed(p), 3)]
return [abs(x) + abs(y) + abs(z) for x, y, z in batched(reversed(p), 3)]


def abs_accel(p):
Expand Down
1 change: 1 addition & 0 deletions aoc_wim/aoc2017/q23.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
https://adventofcode.com/2017/day/23
"""
from aocd import data

from aoc_wim.aoc2017 import Comp

# import logging; logging.basicConfig(format="%(message)s", level=logging.DEBUG)
Expand Down
1 change: 1 addition & 0 deletions aoc_wim/aoc2018/q06.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
https://adventofcode.com/2018/day/6
"""
from io import StringIO

import numpy as np
from aocd import data

Expand Down
2 changes: 2 additions & 0 deletions aoc_wim/aoc2018/q10.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
https://adventofcode.com/2018/day/10
"""
import re

import numpy as np
from aocd import data

from aoc_wim.ocr import AOCR
from aoc_wim.zgrid import ZGrid

Expand Down
1 change: 1 addition & 0 deletions aoc_wim/aoc2018/q18.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
https://adventofcode.com/2018/day/18
"""
import time

import numpy as np
from aocd import data
from scipy.signal import convolve2d
Expand Down
2 changes: 2 additions & 0 deletions aoc_wim/aoc2018/q19.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
https://adventofcode.com/2018/day/19
"""
import math

from aocd import data

from aoc_wim.aoc2018.q16 import all_ops


Expand Down
1 change: 1 addition & 0 deletions aoc_wim/aoc2018/q20.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""
import networkx as nx
from aocd import data

from aoc_wim.zgrid import manhattan_distance
from aoc_wim.zgrid import ZGrid

Expand Down
3 changes: 2 additions & 1 deletion aoc_wim/aoc2018/q22.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
"""
from aocd import data
from parse import parse

from aoc_wim.search import AStar
from aoc_wim.zgrid import zrange
from aoc_wim.zgrid import manhattan_distance
from aoc_wim.zgrid import zrange


# TODO: use zgrid
Expand Down
2 changes: 1 addition & 1 deletion aoc_wim/aoc2018/q23.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
--- Day 23: Experimental Emergency Teleportation ---
https://adventofcode.com/2018/day/23
"""
import math
from heapq import heappop
from heapq import heappush
from itertools import product

import math
import numpy as np
from aocd import data
from parse import parse
Expand Down
Loading

0 comments on commit c1fe58c

Please sign in to comment.