Function advent_of_code::solve

source ·
pub fn solve(year: u16, day: u8, part: u8, input: &str) -> Result<String, String>
Expand description

Returns the solution for the specified given problem and input.

Arguments

  • year - The year of the problem, as in 2018 or 2019.
  • day - The day of the problem - from 1 to 25.
  • part - The part of the problem - either 1 or 2.
  • input - The input to the problem.

Example

use advent_of_code::solve;
let solution = solve(2019, 1, 1, "14");
assert_eq!(solution, Ok("2".to_string()));
Examples found in repository?
src/lib.rs (lines 326-333)
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
pub fn solve_raw(
    year: &str,
    day: &str,
    part: &str,
    input: &str,
    #[cfg(feature = "visualization")] painter: PainterRef,
) -> Result<String, String> {
    let year = year.parse::<u16>().map_err(|_| "Invalid year")?;
    let day = day.parse::<u8>().map_err(|_| "Invalid day")?;
    let part = part.parse::<u8>().map_err(|_| "Invalid part")?;
    solve(
        year,
        day,
        part,
        input,
        #[cfg(feature = "visualization")]
        painter,
    )
}