From 777b9dce30efb1a9c012b969d1096eba1b5d3eb0 Mon Sep 17 00:00:00 2001 From: pjht Date: Wed, 7 Dec 2022 13:30:08 -0600 Subject: [PATCH] Remove unnecessary pub modifiers --- src/day01.rs | 6 +++--- src/day02.rs | 16 ++++++++-------- src/day03.rs | 16 ++++++++-------- src/day04.rs | 6 +++--- src/day05.rs | 20 ++++++++++---------- src/day07.rs | 2 +- 6 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/day01.rs b/src/day01.rs index b115068..58aa792 100644 --- a/src/day01.rs +++ b/src/day01.rs @@ -1,7 +1,7 @@ use aoc_runner_derive::{aoc, aoc_generator}; #[aoc_generator(day1)] -pub fn input_generator(input: &str) -> Vec> { +fn input_generator(input: &str) -> Vec> { input .lines() .collect::>() @@ -11,14 +11,14 @@ pub fn input_generator(input: &str) -> Vec> { } #[aoc(day1, part1)] -pub fn solve_part1(input: &[Vec]) -> u64 { +fn solve_part1(input: &[Vec]) -> u64 { let mut sums = input.iter().map(|el| el.iter().sum()).collect::>(); sums.sort(); sums.pop().unwrap() } #[aoc(day1, part2)] -pub fn solve_part2(input: &[Vec]) -> u64 { +fn solve_part2(input: &[Vec]) -> u64 { let mut sums = input.iter().map(|el| el.iter().sum()).collect::>(); sums.sort(); sums[sums.len() - 3..sums.len()].iter().sum() diff --git a/src/day02.rs b/src/day02.rs index 430a17c..900a1d4 100644 --- a/src/day02.rs +++ b/src/day02.rs @@ -3,10 +3,10 @@ use std::str::FromStr; use aoc_runner_derive::{aoc, aoc_generator}; #[derive(Copy, Clone, Debug)] -pub struct InvalidMove; +struct InvalidMove; #[derive(Copy, Clone, Debug, PartialEq, Eq)] -pub enum Move { +enum Move { Rock, Paper, Scissors, @@ -50,7 +50,7 @@ impl FromStr for Move { } #[derive(Copy, Clone, Debug, PartialEq, Eq)] -pub enum Outcome { +enum Outcome { Lose, Draw, Win, @@ -75,7 +75,7 @@ impl Outcome { } #[derive(Copy, Clone, Debug)] -pub struct InvalidOutcome; +struct InvalidOutcome; impl FromStr for Outcome { type Err = InvalidOutcome; @@ -91,7 +91,7 @@ impl FromStr for Outcome { } #[aoc_generator(day2, part1)] -pub fn input_generator_part1(input: &str) -> Vec<(Move, Move)> { +fn input_generator_part1(input: &str) -> Vec<(Move, Move)> { input .lines() .map(|line| { @@ -102,7 +102,7 @@ pub fn input_generator_part1(input: &str) -> Vec<(Move, Move)> { } #[aoc(day2, part1)] -pub fn solve_part1(input: &[(Move, Move)]) -> u64 { +fn solve_part1(input: &[(Move, Move)]) -> u64 { input .iter() .map(|&(opp, you)| you.shape_score() + you.round_score(opp)) @@ -110,7 +110,7 @@ pub fn solve_part1(input: &[(Move, Move)]) -> u64 { } #[aoc_generator(day2, part2)] -pub fn input_generator_part2(input: &str) -> Vec<(Move, Outcome)> { +fn input_generator_part2(input: &str) -> Vec<(Move, Outcome)> { input .lines() .map(|line| { @@ -121,7 +121,7 @@ pub fn input_generator_part2(input: &str) -> Vec<(Move, Outcome)> { } #[aoc(day2, part2)] -pub fn solve_part2(input: &[(Move, Outcome)]) -> u64 { +fn solve_part2(input: &[(Move, Outcome)]) -> u64 { input .iter() .map(|&(opp, outcome)| { diff --git a/src/day03.rs b/src/day03.rs index 3a9229d..cd0f348 100644 --- a/src/day03.rs +++ b/src/day03.rs @@ -3,16 +3,16 @@ use std::str::FromStr; use aoc_runner_derive::{aoc, aoc_generator}; #[derive(Debug, Default)] -pub struct Rucksack { +struct Rucksack { first_half: Vec, second_half: Vec, } #[derive(Debug, Copy, Clone)] -pub struct NoItemInBothHalves; +struct NoItemInBothHalves; #[derive(Debug, Copy, Clone)] -pub struct NoCommonItem; +struct NoCommonItem; impl Rucksack { fn find_item_in_both_halves(&self) -> Result { @@ -38,7 +38,7 @@ impl Rucksack { } #[derive(Debug, Copy, Clone)] -pub struct InvalidRucksack; +struct InvalidRucksack; impl FromStr for Rucksack { type Err = InvalidRucksack; @@ -65,12 +65,12 @@ impl FromStr for Rucksack { } #[aoc_generator(day3, part1)] -pub fn input_generator_part1(input: &str) -> Vec { +fn input_generator_part1(input: &str) -> Vec { input.lines().map(|l| l.parse().unwrap()).collect() } #[aoc_generator(day3, part2)] -pub fn input_generator_part2(input: &str) -> Vec> { +fn input_generator_part2(input: &str) -> Vec> { input .lines() .collect::>() @@ -84,7 +84,7 @@ pub fn input_generator_part2(input: &str) -> Vec> { } #[aoc(day3, part1)] -pub fn solve_part1(input: &[Rucksack]) -> u64 { +fn solve_part1(input: &[Rucksack]) -> u64 { input .iter() .map(|rucksack| rucksack.find_item_in_both_halves().unwrap() as u64) @@ -92,7 +92,7 @@ pub fn solve_part1(input: &[Rucksack]) -> u64 { } #[aoc(day3, part2)] -pub fn solve_part2(input: &[Vec]) -> u64 { +fn solve_part2(input: &[Vec]) -> u64 { input .iter() .map(|rucksacks| rucksacks[0].find_common_item(&rucksacks[1..]).unwrap() as u64) diff --git a/src/day04.rs b/src/day04.rs index 5b069ce..69deaf5 100644 --- a/src/day04.rs +++ b/src/day04.rs @@ -8,7 +8,7 @@ fn parse_range(range: &str) -> RangeInclusive { } #[aoc_generator(day4)] -pub fn input_generator(input: &str) -> Vec<(RangeInclusive, RangeInclusive)> { +fn input_generator(input: &str) -> Vec<(RangeInclusive, RangeInclusive)> { input .lines() .map(|l| { @@ -27,7 +27,7 @@ fn overlaps_with_range(slf: &RangeInclusive, other: &RangeInclusive) - } #[aoc(day4, part1)] -pub fn solve_part1(input: &[(RangeInclusive, RangeInclusive)]) -> usize { +fn solve_part1(input: &[(RangeInclusive, RangeInclusive)]) -> usize { input .iter() .filter(|(first, second)| contains_range(first, second) | contains_range(second, first)) @@ -35,7 +35,7 @@ pub fn solve_part1(input: &[(RangeInclusive, RangeInclusive)]) -> usiz } #[aoc(day4, part2)] -pub fn solve_part2(input: &[(RangeInclusive, RangeInclusive)]) -> usize { +fn solve_part2(input: &[(RangeInclusive, RangeInclusive)]) -> usize { input .iter() .filter(|(first, second)| { diff --git a/src/day05.rs b/src/day05.rs index b594e3d..6904e4d 100644 --- a/src/day05.rs +++ b/src/day05.rs @@ -3,25 +3,25 @@ use std::str::FromStr; use aoc_runner_derive::{aoc, aoc_generator}; #[derive(Debug, Clone)] -pub struct Stacks { +struct Stacks { stacks: Vec>, } impl Stacks { - pub fn apply_instruction(&mut self, ins: &Instruction) { + fn apply_instruction(&mut self, ins: &Instruction) { for _ in 0..(ins.count) { let crte = self.stacks[ins.from - 1].pop().unwrap(); self.stacks[ins.to - 1].push(crte); } } - pub fn apply_instruction_in_order(&mut self, ins: &Instruction) { + fn apply_instruction_in_order(&mut self, ins: &Instruction) { let from_stack = &mut self.stacks[ins.from - 1]; let crates = from_stack.split_off(from_stack.len() - ins.count); self.stacks[ins.to - 1].extend_from_slice(&crates); } - pub fn top_crates(&self) -> String { + fn top_crates(&self) -> String { self.stacks .iter() .map(|stack| stack.last().unwrap()) @@ -30,7 +30,7 @@ impl Stacks { } #[derive(Debug, Copy, Clone)] -pub struct InvalidStacks; +struct InvalidStacks; impl FromStr for Stacks { type Err = InvalidStacks; @@ -59,14 +59,14 @@ impl FromStr for Stacks { } #[derive(Debug, Clone)] -pub struct Instruction { +struct Instruction { count: usize, from: usize, to: usize, } #[derive(Debug, Copy, Clone)] -pub struct InvalidInstruction; +struct InvalidInstruction; impl FromStr for Instruction { type Err = InvalidInstruction; @@ -85,7 +85,7 @@ impl FromStr for Instruction { } #[aoc_generator(day5)] -pub fn input_generator(input: &str) -> (Stacks, Vec) { +fn input_generator(input: &str) -> (Stacks, Vec) { let (start, instructions) = input.split_once(&"\n\n").unwrap(); ( start.parse().unwrap(), @@ -97,7 +97,7 @@ pub fn input_generator(input: &str) -> (Stacks, Vec) { } #[aoc(day5, part1)] -pub fn solve_part1(input: &(Stacks, Vec)) -> String { +fn solve_part1(input: &(Stacks, Vec)) -> String { let mut stacks = input.0.clone(); for ins in &input.1 { stacks.apply_instruction(ins); @@ -106,7 +106,7 @@ pub fn solve_part1(input: &(Stacks, Vec)) -> String { } #[aoc(day5, part2)] -pub fn solve_part2(input: &(Stacks, Vec)) -> String { +fn solve_part2(input: &(Stacks, Vec)) -> String { let mut stacks = input.0.clone(); for ins in &input.1 { stacks.apply_instruction_in_order(ins); diff --git a/src/day07.rs b/src/day07.rs index 2c706e4..9db0597 100644 --- a/src/day07.rs +++ b/src/day07.rs @@ -26,7 +26,7 @@ impl DirectoryEntry { } #[derive(Copy, Clone, Debug)] -pub struct InvalidDirectoryEntry; +struct InvalidDirectoryEntry; impl FromStr for DirectoryEntry { type Err = InvalidDirectoryEntry;