Giter VIP home page Giter VIP logo

aoc's Introduction

aoc

Advent of Code runner

Assumptions

We assume that:

  • Your code is written in Python 3.
  • Program filename is <part>.py (e.g. part 1: 1.py)
  • Live input is <part>.txt (e.g. part 1: 1.txt)
  • Live output is <part>.out.txt (e.g. part 1: 1.out.txt)
  • All test cases input must be of the format t<part>{suffix}.txt, where suffix can be optional (e.g. part 1 can have t1.txt or t1.1.txt)
  • All test cases output must be of the format t<part>{suffix}.out.txt, where suffix can be optional (e.g. part 1 can have t1.out.txt or t1.1.out.txt)

Note that live input/output means your actual inputs/outputs for the problem. You can also have as many test cases as you want, but we only handle 1 live input.

Installation

No official crate release for now; this must be compiled and installed manually:

git clone https://github.com/yamgent/aoc.git
cd aoc
cargo install --path .

How to Use

All examples below assume you want to run part 1.

Run code against live input

aoc run 1

Run code against another input

For example, to run for my_input.txt:

aoc run 1 my_input

Write live output

aoc write 1

Write output for another input

For example, to run for my_input.txt and get my_input.out.txt:

aoc write 1 my_input

Run all test cases

Note that both pairs of input and output must exist (pairs are determined by t<part>{suffix}, so t1.1.txt pairs with t1.1.out.txt), otherwise the test case will also fail.

Optionally, if live input/output pair exists, this pair will also be tested.

aoc test 1

Run for a particular test case

For example, to test input my_test.txt and expected output my_test.out.txt:

aoc test 1 my_test

Run test cases with diff

In case you want to view the output, you can use the --diff option:

aoc test 1 --diff

Development

We use Rust + cargo for main development, Python 3 for system testing.

For debugging/building:

cargo run
cargo build

For system testing (run in main directory):

python3 testing/system_test.py

aoc's People

Contributors

yamgent avatar

Watchers

 avatar  avatar

aoc's Issues

`test` command: Show progress update

Some programs naturally take a long time to run (e.g. day 15 part 2 for year 2020: https://github.com/yamgent/advent-of-code-2020/tree/61e57c1fbbd5e0a78a4911f41c84fe352de353b7/15, btw this is supposed to be brute-forced, see the folder's NOTE.md).

The user will only be able to see after all test cases are run. The user also cannot cancel the test case runner halfway without losing the results of those tests that have already been executed.

There should be a progress update indicator to show the progress of each test. An example, whereby the first two test cases are completed, and the third is running, we can show this indicator instead of a blank screen:

    t2.1.txt - SUCCESS
(X) t2.2.txt - FAILURE
(-) t2.3.txt - RUNNING
    t2.4.txt - 
    t2.5.txt - 

That way, user can tell the results of the first two test cases, and can abort if needed.

Support `copy` subcommand

This subcommand allows duplicating files belonging to one part, to create a new part. Commonly used once you are done with part 1, and you want it as the foundation for doing your part 2.

For example, if you have 1.txt, 1.out.txt, 1.py, t1.txt, t1.out.txt, but you have no part 2 files yet, and you want to duplicate part 1 files for part 2, do:

aoc copy 1 2

If you already have existing files for part 2 (e.g. 2.py), this subcommand will fail (unlike write). If you really want to override the existing files, you must do:

aoc copy 1 2 --force

Edit: We won't copy output files, the output will definitely be different for the new part.

Edit 2: We can also provide more control over what kind of files to copy over (--code for 1.py, --live for 1.txt, --tests for t1*.txt).

Support `download` command

This subcommand allows you to easily download the live input from the website. Note that we must warn users not to repeatedly call download (e.g. by putting it inside a script loop), as that will be DoS-ing the server.

To download for year 2019, day 5 as live input for part 1:

aoc download 1 --day=2019,5

Support running test cases with pre-defined environment variables

See year 2020, day 9 (https://github.com/yamgent/advent-of-code-2020/tree/85ff321f0bbe0a6210f4080338ec5ed172af791c/09).

The issue is that the test case and actual input uses different window_size (test case: 5, actual: 25), yet the window_size is not part of the input and is instead hard-coded inside the program.

We would like to support running test cases with environment variables, such that test cases can set their own variable values if needed, and programs can just do:

window_size = os.getenv('WINDOW_SIZE') or 25   # actual input will not need to set WINDOW_SIZE

Then, test cases can run by doing WINDOW_SIZE=5 python3 1.py < t1.txt, while normal input is still python3 1.py < 1.txt.

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.