Git Product home page Git Product logo

aoc_driver's Introduction

Aoc Helpers

All functionality requires AoC session cookie, which you can get from you browser after logging in

(look in developer tools)

The most obvious way to use this library is with the calculate_and_post function

use aoc_driver::*;

fn solution(i: &str) -> String { unimplemented!() }

let session = std::fs::read_to_string(".session.txt").unwrap();
calculate_and_post(
    &session,
    2020,
    1,
    Part1,
    Some("inputs/2020/1.txt"),
    Some("cache/2022/1.json"),
    solution
).unwrap();

There is an even faster way though using the aoc_magic macro

use aoc_driver::*;

fn solution(i: &str) -> String { unimplemented!() }

let session = std::fs::read_to_string(".session.txt").unwrap();
aoc_magic!(&session, 2020:1:1, solution).unwrap()

This macro does the same as the above function call (including creating an inputs and cache directory), but more concisely

aoc_driver's People

Contributors

ben-lichtman avatar vonr avatar zachs18 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

zachs18 vonr

aoc_driver's Issues

trim session token before use

Found out that vim was adding a newline to my session token when I started getting invalid header network errors. Trimming the session token before sending it out might alleviate this problem for others.

Incorrect answer is interpreted as correct if a correct answer has previously been submitted.

If you have previously submitted the correct answer for a particular question (year+day+part), the website appears to respond to new submissions with something along the lines of "You don't seem to be solving the right level. Did you already complete it?" regardless of if the answer is correct. aoc_driver interprets this as response as the server saying the answer is correct.

Idea: Cache the correct answer separately from submission responses (e.g. as an Option<String> for each part).
Then when submitting:

  • If this cached value is Some, compare to it instead of submitting to the website.
  • If the cached value is None, submit to the website.
    • If the website responds "correct", set the cached answer to Some in addition to handling the submission as it currently does.
    • If the server responds "Did you already complete it?", maybe parse the question page for Your puzzle answer was <code>::before [answer]</code> and save that/those into the cache, then handle same as Some case.
    • If the server responds "incorrect", "rate limit", etc. handle the response same as it currently does.

Enable using day{day_number}.txt for aoc_complete!

some external tools, like cargo_aoc will pull input into input/{year_num}/day{day_num}.txt instead of input/{year_num}/{day_num}.txt. Having the aoc_complete macro check for both before deciding there isn't any input might be beneficial.

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.