Aoc

Struct Aoc 

Source
pub struct Aoc { /* private fields */ }

Implementations§

Source§

impl Aoc

Source

pub fn new(day: u8, year: i32) -> Self

Creates a new Aoc.

§Arguments
  • day -> day of aoc you want to solve
  • year -> year of aoc you want to solve
§Examples:
use aoc_bud::Aoc;

// Create a new handler for the first aoc day of 2023
let aoc = Aoc::new(1, 2023);
§Panics

Panics if:

  • .env file is not present
  • AOC_SESSION is not present in .env
  • Current working directory is not writteable
Source

pub fn input(&self) -> String

Returns the input of the puzzle of the corresponding day.

§Examples:
use aoc_bud::Aoc;

let aoc: Aoc = Aoc::new(1, 2023);
let input: String = aoc.input();
§Panics

Panics if:

  • It can’t perform a request
  • Current working directory is not writteable
  • The selected date and year don’t have a puzzle yet or don’t exist
Source

pub fn test_input(&self) -> String

Returns the test input of the puzzle of the corresponding day.

§Examples:
use aoc_bud::Aoc;

let aoc: Aoc = Aoc::new(1, 2023);
let test_input: String = aoc.test_input();
§Panics

Panics if:

  • It can’t perform a request
  • It can’t find the test input in the webpage
  • Current working directory is not writteable
  • The selected date and year don’t have a puzzle yet or don’t exist
Source

pub fn solve1<T: ToString>(&self, solution: T) -> Result<(), String>

Send the solution for the first puzzle, will return Ok if correct.

§Argument
  • solution -> your solution
§Example:
use aoc_bud::Aoc;

let aoc: Aoc = Aoc::new(1, 2023);
let input: String = aoc.input();

let solution = get_solution(input);
// Unwrap so we can get the result
aoc.solve1(solution).unwrap();
§Errors

This function will return an error if:

  • It can’t perform a request
  • The solution is incorrect
  • You sent the solution too quickly
  • You are trying to solve a puzzle already solved
  • The selected date and year don’t have a puzzle yet or don’t exist
Source

pub fn solve2<T: ToString>(&self, solution: T) -> Result<(), String>

Send the solution for the second puzzle, will return Ok if correct.

§Argument
  • solution -> your solution
§Example:
use aoc_bud::Aoc;

let aoc: Aoc = Aoc::new(1, 2023);
let input: String = aoc.input();

let solution = get_solution(input);
// Unwrap so we can get the result
aoc.solve2(solution).unwrap();
§Errors

This function will return an error if:

  • It can’t perform a request
  • The solution is incorrect
  • You sent the solution too quickly
  • You are trying to solve a puzzle already solved
  • You are trying to solve the 2nd puzzle without having solved the 1st
  • The selected date and year don’t have a puzzle yet or don’t exist

Auto Trait Implementations§

§

impl Freeze for Aoc

§

impl RefUnwindSafe for Aoc

§

impl Send for Aoc

§

impl Sync for Aoc

§

impl Unpin for Aoc

§

impl UnwindSafe for Aoc

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.