Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reuse generator outputs #57

Open
jhenninger opened this issue Dec 1, 2020 · 0 comments
Open

Reuse generator outputs #57

jhenninger opened this issue Dec 1, 2020 · 0 comments

Comments

@jhenninger
Copy link

Right now the generator function is run again before each part, even if all parts request exactly the same input. This wastes computation time because the puzzle input has to be parsed and transformed at least twice.

It would be preferable if the output of the generator function could be reused, especially if the solver functions only take immutable references, like the examples in the readme.

For example, if the generator returns a Vec,

#[aoc_generator(day2)]
pub fn input_generator(input: &str) -> Vec<Gift> {
    // ...
}

and the solvers take an immutable slice or another reference type,

#[aoc(day2, part1)]
pub fn solve_part1(input: &[Gift]) -> u32 {
    // ...
}

#[aoc(day2, part2)]
pub fn solve_part2(input: &[Gift]) -> u32 {
    // ...
}

it should be possible to use the same Vec returned by the generator for both solvers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant