Coder Social home page Coder Social logo

advent_of_code_2021's Introduction

Eric's Advent of Code 2021 Solutions

The Blog

I've blogged my approaches to the Julia version of each solution here: Advent of Code Blog. Each one includes not only the code but some commentary on the thinking behind the approach and my thoughts about the puzzles in general.

Project Structure

This year, I plan on tackling AoC with Julia. I've dabbled a bit with Julia off and on over the past year, and this seemed like a golden opportunity to really put the langauge through it's paces. Because I know myself, I'm leaving room in the top level of this project to accommodate other languages as I have time/it strikes my fancy. For now, though, there's just JuliaAdventOfCode.

Julia Project

The Julia project structure looks like this:

JuliaAdventOfCode
├─inputs
│ └─DayXX
│   ├─input.txt
│   └─test.txt
├─src
│ ├─DayXX
│ │ ├─DayXX.jl
│ │ ├─Part01.jl
│ │ └─Part02.jl
│ ├─Benchmark.jl
│ ├─JuliaAdventOfCode.jl
│ └─RunAll.jl
├─tests
│ ├─DayXXTests.jl
│ └─runtests.jl
├─Manifest.toml
└─Project.toml

With the JuliaAdventOfCode package activated (see below):

  • Get the results for all days with julia src/RunAll.jl
  • Get the results for a single day with julia src/RunAll.jl -d 1
  • Get the benchmarks for all days with julia src/Benchmark.jl
  • Get the benchmarks for a single day with julia src/Benchmark.jl -d 1
  • Run the tests with julia test/runtests.jl from the terminal
    • Alternatively, you can run the tests in the REPL in Pkg mode

For Day 1, that looks like:

❯ julia src/RunAll.jl -d 1

Advent of Code 2021 Results:

Day 01
├─ Part 01: 1583
└─ Part 02: 1627
❯ julia src/Benchmark.jl -d 1

Julia Advent of Code 2021 Benchmarks:

Day 01:
├─ Part 01:  2.987 μs (5 allocations: 20.31 KiB)
└─ Part 02:  4.561 μs (6 allocations: 36.06 KiB)

Note on Julia project activation

To conveniently use the commands listed above, add the following to your /.julia/config/startup.jl:

using Pkg
if isfile("Project.toml") && isfile("Manifest.toml")
    Pkg.activate(".")
end

advent_of_code_2021's People

Contributors

ericwburden avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.