Coder Social home page Coder Social logo

advent_of_code_2022's Introduction

Advent of Code 2022 daily solutions

In these solutions I strive for elegance, generality, and efficiency, simultaneously if possible. Time-to-solution was not a metric I measured myself by, preferring aesthetics above all. The ultimate goal is to solve each problem in a purely functional paradigm, with no loops or mutable local variables. To this end, I've written a decorator, @tail_recursive, which allows writing tail-recursive functions in a purely functional style without incurring unbounded stack height and extra function calls. This operates at the byte code level. I experimented with an AST-based solution, but found operating at the byte code level more satisfactory. This does mean that much of the code in this repo is restricted to running in CPython (as opposed to e.g. PyPy).

Initialize the environment

From repo root, run:

pipenv install --dev

Run a solution

# help on the commands documented below
./main --help

# run solution to day 1 problem
./main run 1

# show info about the day 10 problem, including optional arguments that can be passed with --args <name>=<json_value>
./main info 10

# run tests for day 12 problem
./main test 12

# run day 24 solution with particular input read from stdin as opposed to the default input file
cat my_input.txt | ./main run 24
...................................................................................................
..........................................................................................o........
.........................................................................................ooo.......
........................................................................................ooooo......
.......................................................................................#ooooo#.....
......................................................................................o#ooooo#.....
.....................................................................................oo#ooooo#.....
....................................................................................oo##ooooo######
...................................................................................ooo#ooooooo....#
..................................................................................oooo#oooooooo...#
.................................................................................ooooo#ooooooooo..#
................................................................................oooooo#############
...............................................................................oooooooo............
..............................................................................oooooooooo...........
.............................................................................ooooooo#o#oo..........
............................................................................oooooooo#o#ooo.........
...........................................................................ooooooooo#o#oooo........
..........................................................................oo#########o#######......
.........................................................................ooo#.......ooo.....#......
........................................................................oooo#......ooooo....#......
.......................................................................ooooo#################......
......................................................................ooooooo......................
.....................................................................ooooooooo.....................
....................................................................#oooooooooo.#..................
....................................................................#############..................
...................................................................................................
...................................................................................................
..................................................................oo...............................
.................................................................oooo..............................
.............................................................#..oooooo.............................
.............................................................##########............................
...................................................................................................
.......................................................................o...........................
......................................................................ooo#.........................
.....................................................................oooo#.........................
....................................................................ooooo#.........................
...................................................................oooooo#.........................
..................................................................o#ooooo#.........................
.................................................................oo#ooooo#.#.......................
................................................................ooo#ooooo#.#.......................
...............................................................oooo#o#o#o#.#.......................
..............................................................ooo#o#o#o#o#.#.......................
.............................................................oooo#o#o#o#o#.#.......................
............................................................ooooo###########.......................
...........................................................ooooooo.................................
..........................................................ooooooooo................................
.........................................................ooooo#####o...............................
........................................................ooooooo...ooo..............................
.......................................................oooo#####.#####.............................
......................................................oooooo.......................................
.....................................................ooo#####.#####.#####..........................
....................................................ooooo..........................................
...................................................oo#####.#####.#####.#####.......................
..................................................oooo.............................................
.................................................o#####.#####.#####.#####.#####....................
................................................ooo................................................
...............................................ooooo...............................................
..............................................#ooooo#..............................................
..............................................#ooooo#..............................................
..............................................#ooooo#..............................................
.............................................o#ooooo#..............................................
............................................o##ooooo#####..........................................
...........................................oo#ooooooo...#..........................................
..........................................ooo#oooooooo..#..........................................
.........................................oooo#ooooooooo.#..........................................
........................................ooooo#oooooooooo#..........................................
.......................................oooooo#oooooooooo#..........................................
......................................ooooooo#oooooooooo#..........................................
.....................................oooooooo############..........................................
....................................oooooooooo.....................................................
...................................oooo#ooooooo....................................................
..................................ooooo###############.............................................
.................................ooooooo...........................................................
................................ooooooooo..........................................................
...............................ooooo#####o.........................................................
..............................ooooooo...ooo........................................................
.............................oooo#####.#####.......................................................
............................oooooo.................................................................
...........................ooo#####.#####.#####....................................................
..........................ooooo....................................................................
.........................ooooooo...................................................................
........................ooo#####o..................................................................
.......................ooooo...ooo.................................................................
......................oo#####.#####................................................................
.....................oooo..........................................................................
....................o#####.#####.#####.............................................................
...................ooo.............................................................................
..................#####.#####.#####.#####..........................................................
.................o.................................................................................
................ooo................................................................................
...............#####...............................................................................
..............o....................................................................................
.............ooo...................................................................................
............#####.#####............................................................................
..........oo.......................................................................................
.........oooo......................................................................................
........o#####.#####.#####.........................................................................
.......ooo.........................................................................................
......ooooo........................................................................................
#....o#ooooo.o#....................................................................................
#...oo#ooooooo#....................................................................................
#..ooo#ooooooo#....................................................................................
#.oooo#ooooooo#....................................................................................
#ooooo#o#ooooo#....................................................................................
#ooooo#o#ooooo#....................................................................................
#o#ooo#o#ooooo#....................................................................................
#o#o#o#o#ooooo#....................................................................................
#o#o#o#o#o#o#o#....................................................................................
#o#o#o#o#o#o#o#....................................................................................
###############....................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
.............#.....................................................................................
.............#.....................................................................................
.............#oo...................................................................................
...........#.#ooo..................................................................................
...........#.#ooo#.................................................................................
...........#.#ooo#.................................................................................
...........#.#o#o#.................................................................................
...........#######.................................................................................
...................................................................................................
.................oo................................................................................
..........#.....ooo#...............................................................................
..........##########...............................................................................
...................................................................................................
....................o..............................................................................
...................#oo.#...........................................................................
...................#ooo#...........................................................................
..................##ooo####........................................................................
..................#ooooo..#........................................................................
..................#oooooo.#........................................................................
..................#ooooooo#........................................................................
..................#ooooooo#........................................................................
..................#ooooooo#........................................................................
..................#########........................................................................
...................................................................................................
.................o.................................................................................
................ooo................................................................................
...............ooooo...............................................................................
..............ooooooo..............................................................................
.............#oooooooo.............................................................................
............o#ooooo#ooo#...........................................................................
...........oo#ooooo#ooo#...........................................................................
..........ooo#o#ooo#o#o#...........................................................................
.........#ooo#o#o#o#o#o#...........................................................................
.........#ooo#o#o#o#o#o#...........................................................................
.........#o#o#o#o#o#o#o#...........................................................................
.........###############...........................................................................

day 14 sample output

advent_of_code_2022's People

Contributors

matthawthorn avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.