Giter VIP home page Giter VIP logo

aoc-tool's Introduction

aoc-tool

Organize, download, write, test, and submit Advent of Code puzzles from the command line!

aoc-tool offers a language-agnostic way to solve AoC puzzles from the comfort of the terminal.

aoc-tool is a work-in-progress. It is currently useable but not well-tested and not feature-complete

aoc_demo

Install

Depends on: Ruby

From source:

$ git clone https://github.com/mxple/aoc-tool  # somewhere safe
$ cd aoc-tool
$ ln -s $(pwd)/bin/aoc.rb /usr/bin/aoc

Windows people, use WSL until Windows is officially supported :p

Getting Started

Run aoc config-gen > ~/.config/aoc/config.rb to generate a sample config file.

Modify the variables:

$SESSION      = 'your_session_cookie'
$MASTER_DIR   = '/path/to/master/dir'
$DEFAULT_LANG = 'your favorite language'
$IDE          = 'command to run ide (see wiki)'

That's all the configuration most users will need!

Then, initialize the master directory:

$ aoc init-master  # creates master_dir and some metadata

Choose a year to start off with:

$ aoc init-year 2023 aoc2023  # creates master_dir/aoc2023 and some metadata

Download a puzzle, sets up work space, and open an IDE:

$ aoc create 2023 1 rust

Happy coding! Once you finish a solution, you can run it like so:

$ aoc run   # run specified puzzle or last init-ed puzzle

Runs are language agnostic! If your language isn't automatically supported, you can add support in the config file.

Finally, submit with:

$ aoc submit  # submits last run's output, or a specified year, day, and answer

For more information about commands and usage:

$ aoc help

Or check the wiki (wip)!

Features

Smart commands can parse ambigous arguments:

aoc create 4 rs  # download puzzle 4 for latest AoC year and makes 2 rust files from templates
aoc r 3 2017     # runs solution for puzzle 3 of 2017, argument order doesn't (really) matter
aoc create       # download latest available puzzle

Input fed via environment variables, STDIN, and file:

lines = os.getenv('AOC_INPUT').splitlines()
lines = [line.strip() for line in sys.stdin]
lines = [line.strip() for line in open(os.getenv('AOC_INPUT_PATH')] 

The above four are all identical. Using aoc-tool's supported inputs methods allow for dynamic and fast testing.

Run aoc to download, edit, and run files from any directory:

$ pwd
/usr/bin      # be literally anywhere in your file system
$ aoc init    # download latest puzzle and have your IDE automatically called on the puzzle
$ aoc run     # compile/interpret and run on input data
$ aoc submit  # submit latest run result to corresponding puzzle

Organize the way you prefer with a multitude of config options. Specify how files are named and how directories should be laid out:

# Two file trees generated with different configs
master                       |     master
├── advent22                 |     ├── advent22                
│   └── solutions            |     │   ├── inputs             
│       └── 04               |     │   │   └── 04.txt         
│           ├── input.txt    |     │   └── solutions          
│           ├── p1.py        |     │       └── 04             
│           └── p2.java      |     │           ├── part1.rs      
└── aoc2023                  |     │           └── part2.rs      
    └── solutions            |     └── aoc2023                
        ├── 01               |         ├── inputs             
        │   ├── input.txt    |         │   ├── 01.txt         
        │   ├── p1.py        |         │   └── 02.txt         
        │   └── p2.py        |         └── solutions          
        └── 02               |             ├── 01             
            ├── input.txt    |             │   ├── part1.py      
            ├── p1.hs        |             │   └── part2.py      
            └── p2.exs       |             └── 02             
                             |                 ├── part1.rb      
                             |                 └── part2.rb      

Mixing languages, even within the same puzzle, is valid! Adding .md writeup files to the puzzle directory is also okay.

Advanced Features

aoc-tool also offers some features for advanced users:

  • Support for custom libraries to compile with
  • Add support for less popular languages via config
  • Write Ruby code in config for more nuanced behavior

Contributing

Contributions, especially for adding language support, are very welcome!

aoc-tool's People

Contributors

mxple avatar

Watchers

 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.