Skip to content

Commit

Permalink
chore(rust): remove doc tests since we don't have input in ci
Browse files Browse the repository at this point in the history
  • Loading branch information
believer committed Dec 2, 2024
1 parent 6e79692 commit 085ff53
Show file tree
Hide file tree
Showing 55 changed files with 55 additions and 677 deletions.
12 changes: 0 additions & 12 deletions rust/2015/src/day_01.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ pub fn input_generator(input: &str) -> Input {

/* Part One
*/
/// Your puzzle answer was
/// ```
/// use advent_of_code_2015::day_01::*;
/// let data = include_str!("../input/2015/day1.txt");
/// assert_eq!(solve_part_01(&input_generator(data)), 232);
/// ```
#[aoc(day1, part1)]
pub fn solve_part_01(directions: &Input) -> isize {
directions
Expand All @@ -41,12 +35,6 @@ pub fn solve_part_01(directions: &Input) -> isize {

/* Part Two
*/
/// Your puzzle answer was
/// ```
/// use advent_of_code_2015::day_01::*;
/// let data = include_str!("../input/2015/day1.txt");
/// assert_eq!(solve_part_02(&input_generator(data)), 1783);
/// ```
#[aoc(day1, part2)]
pub fn solve_part_02(directions: &Input) -> usize {
let mut floor = 0;
Expand Down
12 changes: 0 additions & 12 deletions rust/2015/src/day_02.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ A present with dimensions 1x1x10 requires 2*1 + 2*10 + 2*10 = 42 square feet of
All numbers in the elves' list are in feet. How many total square feet of wrapping paper should they order?
*/
// Your puzzle answer was
/// ```
/// use advent_of_code_2015::day_02::*;
/// let data = include_str!("../input/2015/day2.txt");
/// assert_eq!(solve_part_01(&input_generator(data)), 1586300);
/// ```
#[aoc(day2, part1)]
pub fn solve_part_01(input: &[(u32, u32, u32)]) -> u32 {
input.iter().fold(0, |sum, (length, width, height)| {
Expand All @@ -62,12 +56,6 @@ A present with dimensions 1x1x10 requires 1+1+1+1 = 4 feet of ribbon to wrap the
How many total feet of ribbon should they order?
*/
// Your puzzle answer was
/// ```
/// use advent_of_code_2015::day_02::*;
/// let data = include_str!("../input/2015/day2.txt");
/// assert_eq!(solve_part_02(&input_generator(data)), 3737498);
/// ```
#[aoc(day2, part2)]
pub fn solve_part_02(input: &[(u32, u32, u32)]) -> u32 {
input.iter().fold(0, |sum, (length, width, height)| {
Expand Down
12 changes: 0 additions & 12 deletions rust/2015/src/day_03.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,6 @@ pub fn input_generator(input: &str) -> Input {

/* Part One
*/
/// Your puzzle answer was
/// ```
/// use advent_of_code_2015::day_03::*;
/// let data = include_str!("../input/2015/day3.txt");
/// assert_eq!(solve_part_01(&input_generator(data)), 2572);
/// ```
#[aoc(day3, part1)]
pub fn solve_part_01(input: &Input) -> usize {
let mut houses: HashSet<(isize, isize)> = HashSet::with_capacity(input.len());
Expand All @@ -83,12 +77,6 @@ pub fn solve_part_01(input: &Input) -> usize {

/* Part Two
*/
/// Your puzzle answer was
/// ```
/// use advent_of_code_2015::day_03::*;
/// let data = include_str!("../input/2015/day3.txt");
/// assert_eq!(solve_part_02(&input_generator(data)), 2631);
/// ```
#[aoc(day3, part2)]
pub fn solve_part_02(input: &Input) -> usize {
let mut houses: HashSet<(isize, isize)> = HashSet::with_capacity(input.len());
Expand Down
5 changes: 0 additions & 5 deletions rust/2016/src/day_01.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@ pub fn input_generator(input: &str) -> Vec<Instruction> {

/* Part One
*/
/// Your puzzle answer was
/// ```
/// use advent_of_code_2016::day_01::*;
/// let input = include_str!("../input/2016/day1.txt");
/// assert_eq!(solve_part_01(&input_generator(input)), 252);
#[aoc(day1, part1)]
pub fn solve_part_01(instructions: &[Instruction]) -> u32 {
let mut cab = Cab::new();
Expand Down
6 changes: 0 additions & 6 deletions rust/2016/src/day_03.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ pub fn input_generator(input: &str) -> Input {

/* Part One
*/
/// Your puzzle answer was
/// ```
/// use advent_of_code_2016::day_03::*;
/// let data = include_str!("../input/2016/day3.txt");
/// assert_eq!(solve_part_01(&input_generator(data)), 862);
/// ```
#[aoc(day3, part1)]
pub fn solve_part_01(input: &Input) -> usize {
input
Expand Down
12 changes: 0 additions & 12 deletions rust/2019/src/day_01.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,13 @@ fn calculate_fuel_with_extra(mass: &i32, total_fuel: i32) -> i32 {

/* Part One
*/
/// Your puzzle answer was
/// ```
/// use advent_of_code_2019::day_01::*;
/// let data = include_str!("../input/2019/day1.txt");
/// assert_eq!(solve_part_01(&input_generator(data)), 3553700);
/// ```
#[aoc(day1, part1)]
pub fn solve_part_01(fuel: &Fuel) -> i32 {
fuel.iter().map(calculate_fuel).sum()
}

/* Part Two
*/
/// Your puzzle answer was
/// ```
/// use advent_of_code_2019::day_01::*;
/// let data = include_str!("../input/2019/day1.txt");
/// assert_eq!(solve_part_02(&input_generator(data)), 5327664);
/// ```
#[aoc(day1, part2)]
pub fn solve_part_02(fuel: &Fuel) -> i32 {
fuel.iter().map(|f| calculate_fuel_with_extra(f, 0)).sum()
Expand Down
12 changes: 0 additions & 12 deletions rust/2020/src/day_01.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ pub fn input_generator(input: &str) -> HashSet<u32> {
*
* Of course, your expense report is much larger. Find the two entries that sum to 2020; what do you get if you multiply them together?
*/
/// Your puzzle answer was
/// ```
/// use advent_of_code_2020::day_01::*;
/// let data = include_str!("../input/2020/day1.txt");
/// assert_eq!(solve_part_01(&input_generator(data)), 898299);
/// ```
#[aoc(day1, part1)]
pub fn solve_part_01(input: &HashSet<u32>) -> u32 {
for x in input {
Expand All @@ -66,12 +60,6 @@ pub fn solve_part_01(input: &HashSet<u32>) -> u32 {
*
* In your expense report, what is the product of the three entries that sum to 2020?
*/
/// Your puzzle answer was
/// ```
/// use advent_of_code_2020::day_01::*;
/// let data = include_str!("../input/2020/day1.txt");
/// assert_eq!(solve_part_02(&input_generator(data)), 143933922);
/// ```
#[aoc(day1, part2)]
pub fn solve_part_02(input: &HashSet<u32>) -> u32 {
for x in input {
Expand Down
20 changes: 4 additions & 16 deletions rust/2020/src/day_02.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ use std::ops::RangeInclusive;
// Fastest, also a very clean solution, seems to be using a RegEx

lazy_static! {
/// Input is in the form "1-3 a: abcdef"
// Input is in the form "1-3 a: abcdef"
static ref RE: Regex = Regex::new(r"(\d+)-(\d+) (\w): (\w*)").unwrap();
}

/// Official Toboggan Corporate Policy
// Official Toboggan Corporate Policy
pub struct OTCP {
password: String,
policy: char,
Expand Down Expand Up @@ -78,12 +78,6 @@ pub fn input_generator(input: &str) -> Vec<OTCP> {
*
* How many passwords are valid according to their policies?
*/
///Your puzzle answer was
/// ```
/// use advent_of_code_2020::day_02::*;
/// let input = include_str!("../input/2020/day2.txt");
/// assert_eq!(solve_part_01(&input_generator(input)), 524);
/// ```
#[aoc(day2, part1)]
pub fn solve_part_01(input: &[OTCP]) -> usize {
input
Expand Down Expand Up @@ -117,12 +111,6 @@ pub fn solve_part_01(input: &[OTCP]) -> usize {
*
* How many passwords are valid according to the new interpretation of the policies?
*/
///your puzzle answer was
/// ```
/// use advent_of_code_2020::day_02::*;
/// let input = include_str!("../input/2020/day2.txt");
/// assert_eq!(solve_part_02(&input_generator(input)), 485);
/// ```
#[aoc(day2, part2)]
pub fn solve_part_02(input: &[OTCP]) -> usize {
input
Expand All @@ -141,7 +129,7 @@ pub fn solve_part_02(input: &[OTCP]) -> usize {
mod tests {
use super::*;

/// Test example data on part 1
// Test example data on part 1
#[test]
fn sample_01() {
let data = "
Expand All @@ -153,7 +141,7 @@ mod tests {
assert_eq!(solve_part_01(&input_generator(data)), 2)
}

/// Test example data on part 2
// Test example data on part 2
#[test]
fn sample_02() {
let data = "
Expand Down
16 changes: 2 additions & 14 deletions rust/2020/src/day_03.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,6 @@ fn slope_finder(input: &[String], rs: &usize, cs: &usize) -> u32 {
*
* Starting at the top-left corner of your map and following a slope of right 3 and down 1, how many trees would you encounter?
*/
///your puzzle answer was.
/// ```
/// use advent_of_code_2020::day_03::*;
/// let input = include_str!("../input/2020/day3.txt");
/// assert_eq!(solve_part_01(&input_generator(input)), 259);
/// ```
#[aoc(day3, part1)]
pub fn solve_part_01(input: &[String]) -> u32 {
slope_finder(input, &1, &3)
Expand All @@ -120,12 +114,6 @@ pub fn solve_part_01(input: &[String]) -> u32 {
*
* What do you get if you multiply together the number of trees encountered on each of the listed slopes?
*/
///your puzzle answer was.
/// ```
/// use advent_of_code_2020::day_03::*;
/// let input = include_str!("../input/2020/day3.txt");
/// assert_eq!(solve_part_02(&input_generator(input)), 2224913600);
/// ```
#[aoc(day3, part2)]
pub fn solve_part_02(input: &[String]) -> u32 {
[(1, 1), (1, 3), (1, 5), (1, 7), (2, 1)]
Expand All @@ -137,7 +125,7 @@ pub fn solve_part_02(input: &[String]) -> u32 {
mod tests {
use super::*;

/// Test example data on part 1
// Test example data on part 1
#[test]
fn sample_01() {
let data = "
Expand All @@ -157,7 +145,7 @@ mod tests {
assert_eq!(solve_part_01(&input_generator(data)), 7)
}

/// Test example data on part 2
// Test example data on part 2
#[test]
fn sample_02() {
let data = "
Expand Down
16 changes: 2 additions & 14 deletions rust/2020/src/day_04.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,6 @@ pub fn input_generator_part_02(input: &str) -> Vec<Passport> {
* Count the number of valid passports - those that have all required fields.
* Treat cid as optional. In your batch file, how many passports are valid?
*/
///your puzzle answer was.
/// ```
/// use advent_of_code_2020::day_04::*;
/// let input = include_str!("../input/2020/day4.txt");
/// assert_eq!(solve_part_01(&input_generator_part_01(input)), 200);
/// ```
#[aoc(day4, part1)]
pub fn solve_part_01(input: &[Passport]) -> usize {
input
Expand Down Expand Up @@ -165,12 +159,6 @@ pub fn solve_part_01(input: &[Passport]) -> usize {
* Count the number of valid passports - those that have all required fields and valid values.
* Continue to treat cid as optional. In your batch file, how many passports are valid?
*/
///your puzzle answer was.
/// ```
/// use advent_of_code_2020::day_04::*;
/// let input = include_str!("../input/2020/day4.txt");
/// assert_eq!(solve_part_02(&input_generator_part_02(input)), 116);
/// ```
#[aoc(day4, part2)]
pub fn solve_part_02(input: &[Passport]) -> usize {
input.iter().filter(|passport| passport.is_valid()).count()
Expand All @@ -180,7 +168,7 @@ pub fn solve_part_02(input: &[Passport]) -> usize {
mod tests {
use super::*;

/// Test example data on part 1
// Test example data on part 1
#[test]
fn sample_01() {
let data = "
Expand All @@ -202,7 +190,7 @@ iyr:2011 ecl:brn hgt:59in
assert_eq!(solve_part_01(&input_generator_part_01(data)), 2)
}

/// Test example data on part 2
// Test example data on part 2
#[test]
fn sample_data_invalid_02() {
let data = "
Expand Down
14 changes: 1 addition & 13 deletions rust/2020/src/day_05.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,6 @@ fn find_airplane_seats(input: &[String]) -> Vec<u32> {
* BBFFBBFRLL: row 102, column 4, seat ID 820.
* As a sanity check, look through your list of boarding passes. What is the highest seat ID on a boarding pass?
*/
///your puzzle answer was.
/// ```
/// use advent_of_code_2020::day_05::*;
/// let input = include_str!("../input/2020/day5.txt");
/// assert_eq!(solve_part_01(&input_generator(input)), 866);
/// ```
#[aoc(day5, part1)]
pub fn solve_part_01(input: &[String]) -> u32 {
find_airplane_seats(input).into_iter().max().unwrap()
Expand All @@ -120,12 +114,6 @@ pub fn solve_part_01(input: &[String]) -> u32 {
*
* What is the ID of your seat?
*/
///your puzzle answer was.
/// ```
/// use advent_of_code_2020::day_05::*;
/// let input = include_str!("../input/2020/day5.txt");
/// assert_eq!(solve_part_02(&input_generator(input)), 583);
/// ```
#[aoc(day5, part2)]
pub fn solve_part_02(input: &[String]) -> u32 {
let mut my_seat = 0;
Expand All @@ -145,7 +133,7 @@ pub fn solve_part_02(input: &[String]) -> u32 {
mod tests {
use super::*;

/// Test example data on part 1
// Test example data on part 1
#[test]
fn sample_01() {
let data = "FBFBBFFRLR";
Expand Down
16 changes: 2 additions & 14 deletions rust/2020/src/day_06.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,6 @@ pub fn input_generator_part_02(input: &str) -> Vec<Vec<String>> {
*
* For each group, count the number of questions to which anyone answered "yes". What is the sum of those counts?
*/
///your puzzle answer was.
/// ```
/// use advent_of_code_2020::day_06::*;
/// let input = include_str!("../input/2020/day6.txt");
/// assert_eq!(solve_part_01(&input_generator_part_01(input)), 6778);
/// ```
#[aoc(day6, part1)]
pub fn solve_part_01(input: &[String]) -> usize {
input
Expand Down Expand Up @@ -131,12 +125,6 @@ pub fn solve_part_01(input: &[String]) -> usize {
*
* For each group, count the number of questions to which everyone answered "yes". What is the sum of those counts?
*/
///your puzzle answer was.
/// ```
/// use advent_of_code_2020::day_06::*;
/// let input = include_str!("../input/2020/day6.txt");
/// assert_eq!(solve_part_02(&input_generator_part_02(input)), 3406);
/// ```
#[aoc(day6, part2)]
pub fn solve_part_02(input: &[Vec<String>]) -> usize {
input.iter().fold(0, |acc, group| {
Expand Down Expand Up @@ -168,7 +156,7 @@ pub fn solve_part_02(input: &[Vec<String>]) -> usize {
mod tests {
use super::*;

/// Test example data on part 1
// Test example data on part 1
#[test]
fn sample_01() {
let data = "
Expand All @@ -191,7 +179,7 @@ b

assert_eq!(solve_part_01(&input_generator_part_01(data)), 11)
}
/// Test example data on part 2
// Test example data on part 2
#[test]
fn sample_02() {
let data = "
Expand Down
Loading

0 comments on commit 085ff53

Please sign in to comment.