From 4bacc819a670f4459376523d52487911277a04eb Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Sat, 3 Dec 2022 22:46:42 -0600 Subject: [PATCH] Scaffold remaining days --- 2022/elixir-livebook.livemd | 54 ++++++++++++++++++++++++++++++++++++- 2022/rust/src/day10.rs | 32 ++++++++++++++++++++++ 2022/rust/src/day11.rs | 32 ++++++++++++++++++++++ 2022/rust/src/day12.rs | 32 ++++++++++++++++++++++ 2022/rust/src/day13.rs | 32 ++++++++++++++++++++++ 2022/rust/src/day14.rs | 32 ++++++++++++++++++++++ 2022/rust/src/day15.rs | 32 ++++++++++++++++++++++ 2022/rust/src/day16.rs | 32 ++++++++++++++++++++++ 2022/rust/src/day17.rs | 32 ++++++++++++++++++++++ 2022/rust/src/day18.rs | 32 ++++++++++++++++++++++ 2022/rust/src/day19.rs | 32 ++++++++++++++++++++++ 2022/rust/src/day20.rs | 32 ++++++++++++++++++++++ 2022/rust/src/day21.rs | 32 ++++++++++++++++++++++ 2022/rust/src/day22.rs | 32 ++++++++++++++++++++++ 2022/rust/src/day23.rs | 32 ++++++++++++++++++++++ 2022/rust/src/day24.rs | 32 ++++++++++++++++++++++ 2022/rust/src/day25.rs | 32 ++++++++++++++++++++++ 2022/rust/src/day5.rs | 32 ++++++++++++++++++++++ 2022/rust/src/day6.rs | 32 ++++++++++++++++++++++ 2022/rust/src/day7.rs | 32 ++++++++++++++++++++++ 2022/rust/src/day8.rs | 32 ++++++++++++++++++++++ 2022/rust/src/day9.rs | 32 ++++++++++++++++++++++ 22 files changed, 725 insertions(+), 1 deletion(-) create mode 100644 2022/rust/src/day10.rs create mode 100644 2022/rust/src/day11.rs create mode 100644 2022/rust/src/day12.rs create mode 100644 2022/rust/src/day13.rs create mode 100644 2022/rust/src/day14.rs create mode 100644 2022/rust/src/day15.rs create mode 100644 2022/rust/src/day16.rs create mode 100644 2022/rust/src/day17.rs create mode 100644 2022/rust/src/day18.rs create mode 100644 2022/rust/src/day19.rs create mode 100644 2022/rust/src/day20.rs create mode 100644 2022/rust/src/day21.rs create mode 100644 2022/rust/src/day22.rs create mode 100644 2022/rust/src/day23.rs create mode 100644 2022/rust/src/day24.rs create mode 100644 2022/rust/src/day25.rs create mode 100644 2022/rust/src/day5.rs create mode 100644 2022/rust/src/day6.rs create mode 100644 2022/rust/src/day7.rs create mode 100644 2022/rust/src/day8.rs create mode 100644 2022/rust/src/day9.rs diff --git a/2022/elixir-livebook.livemd b/2022/elixir-livebook.livemd index 32e3c2d..0e56614 100644 --- a/2022/elixir-livebook.livemd +++ b/2022/elixir-livebook.livemd @@ -4,7 +4,7 @@ ```elixir defmodule AoC do - def input_file_contents(n), do: File.read!(Path.expand("~/.cache/aoc2022/#{n}.input")) + def input_file_contents(n), do: File.read!(Path.expand("/aoc-input/#{n}.input")) end import Enum @@ -85,3 +85,55 @@ Part 2: 15457 ``` :ok ``` + +## Day 3 + +```elixir +priority = fn + n when n >= 97 and n <= 122 -> n - 96 + n -> n - 38 +end + +lines = + 3 + |> AoC.input_file_contents() + |> String.split("\n", trim: true) + +lines +|> map(fn s -> + <> = s + + MapSet.new(to_charlist(a)) + |> MapSet.intersection(MapSet.new(to_charlist(b))) + |> MapSet.to_list() + |> hd() + |> priority.() +end) +|> sum() +|> IO.inspect() + +lines +|> chunk_every(3) +|> map(fn t -> + map(t, &(to_charlist(&1) |> MapSet.new())) + |> reduce(&MapSet.intersection/2) + |> MapSet.to_list() + |> hd() + |> priority.() +end) +|> sum() +|> IO.inspect() +``` + + + +``` +7597 +2607 +``` + + + +``` +2607 +``` diff --git a/2022/rust/src/day10.rs b/2022/rust/src/day10.rs new file mode 100644 index 0000000..bc0a3ce --- /dev/null +++ b/2022/rust/src/day10.rs @@ -0,0 +1,32 @@ +mod common; + +fn main() { + let input = common::day_input(panic!("PUT THE CORRECT DAY NUMBER HERE")); + println!("Part 1: {}", part1(&input)); + println!("Part 2: {}", part2(&input)); +} + +fn part1(input: &str) -> i32 { + 0 +} + +fn part2(input: &str) -> i32 { + 0 +} + +#[cfg(test)] +mod tests { + use super::*; + + const TEST_INPUT: &str = ""; + + #[test] + fn test_part1() { + assert_eq!(part1(TEST_INPUT), 0) + } + + #[test] + fn test_part2() { + assert_eq!(part2(TEST_INPUT), 0) + } +} diff --git a/2022/rust/src/day11.rs b/2022/rust/src/day11.rs new file mode 100644 index 0000000..bc0a3ce --- /dev/null +++ b/2022/rust/src/day11.rs @@ -0,0 +1,32 @@ +mod common; + +fn main() { + let input = common::day_input(panic!("PUT THE CORRECT DAY NUMBER HERE")); + println!("Part 1: {}", part1(&input)); + println!("Part 2: {}", part2(&input)); +} + +fn part1(input: &str) -> i32 { + 0 +} + +fn part2(input: &str) -> i32 { + 0 +} + +#[cfg(test)] +mod tests { + use super::*; + + const TEST_INPUT: &str = ""; + + #[test] + fn test_part1() { + assert_eq!(part1(TEST_INPUT), 0) + } + + #[test] + fn test_part2() { + assert_eq!(part2(TEST_INPUT), 0) + } +} diff --git a/2022/rust/src/day12.rs b/2022/rust/src/day12.rs new file mode 100644 index 0000000..bc0a3ce --- /dev/null +++ b/2022/rust/src/day12.rs @@ -0,0 +1,32 @@ +mod common; + +fn main() { + let input = common::day_input(panic!("PUT THE CORRECT DAY NUMBER HERE")); + println!("Part 1: {}", part1(&input)); + println!("Part 2: {}", part2(&input)); +} + +fn part1(input: &str) -> i32 { + 0 +} + +fn part2(input: &str) -> i32 { + 0 +} + +#[cfg(test)] +mod tests { + use super::*; + + const TEST_INPUT: &str = ""; + + #[test] + fn test_part1() { + assert_eq!(part1(TEST_INPUT), 0) + } + + #[test] + fn test_part2() { + assert_eq!(part2(TEST_INPUT), 0) + } +} diff --git a/2022/rust/src/day13.rs b/2022/rust/src/day13.rs new file mode 100644 index 0000000..bc0a3ce --- /dev/null +++ b/2022/rust/src/day13.rs @@ -0,0 +1,32 @@ +mod common; + +fn main() { + let input = common::day_input(panic!("PUT THE CORRECT DAY NUMBER HERE")); + println!("Part 1: {}", part1(&input)); + println!("Part 2: {}", part2(&input)); +} + +fn part1(input: &str) -> i32 { + 0 +} + +fn part2(input: &str) -> i32 { + 0 +} + +#[cfg(test)] +mod tests { + use super::*; + + const TEST_INPUT: &str = ""; + + #[test] + fn test_part1() { + assert_eq!(part1(TEST_INPUT), 0) + } + + #[test] + fn test_part2() { + assert_eq!(part2(TEST_INPUT), 0) + } +} diff --git a/2022/rust/src/day14.rs b/2022/rust/src/day14.rs new file mode 100644 index 0000000..bc0a3ce --- /dev/null +++ b/2022/rust/src/day14.rs @@ -0,0 +1,32 @@ +mod common; + +fn main() { + let input = common::day_input(panic!("PUT THE CORRECT DAY NUMBER HERE")); + println!("Part 1: {}", part1(&input)); + println!("Part 2: {}", part2(&input)); +} + +fn part1(input: &str) -> i32 { + 0 +} + +fn part2(input: &str) -> i32 { + 0 +} + +#[cfg(test)] +mod tests { + use super::*; + + const TEST_INPUT: &str = ""; + + #[test] + fn test_part1() { + assert_eq!(part1(TEST_INPUT), 0) + } + + #[test] + fn test_part2() { + assert_eq!(part2(TEST_INPUT), 0) + } +} diff --git a/2022/rust/src/day15.rs b/2022/rust/src/day15.rs new file mode 100644 index 0000000..bc0a3ce --- /dev/null +++ b/2022/rust/src/day15.rs @@ -0,0 +1,32 @@ +mod common; + +fn main() { + let input = common::day_input(panic!("PUT THE CORRECT DAY NUMBER HERE")); + println!("Part 1: {}", part1(&input)); + println!("Part 2: {}", part2(&input)); +} + +fn part1(input: &str) -> i32 { + 0 +} + +fn part2(input: &str) -> i32 { + 0 +} + +#[cfg(test)] +mod tests { + use super::*; + + const TEST_INPUT: &str = ""; + + #[test] + fn test_part1() { + assert_eq!(part1(TEST_INPUT), 0) + } + + #[test] + fn test_part2() { + assert_eq!(part2(TEST_INPUT), 0) + } +} diff --git a/2022/rust/src/day16.rs b/2022/rust/src/day16.rs new file mode 100644 index 0000000..bc0a3ce --- /dev/null +++ b/2022/rust/src/day16.rs @@ -0,0 +1,32 @@ +mod common; + +fn main() { + let input = common::day_input(panic!("PUT THE CORRECT DAY NUMBER HERE")); + println!("Part 1: {}", part1(&input)); + println!("Part 2: {}", part2(&input)); +} + +fn part1(input: &str) -> i32 { + 0 +} + +fn part2(input: &str) -> i32 { + 0 +} + +#[cfg(test)] +mod tests { + use super::*; + + const TEST_INPUT: &str = ""; + + #[test] + fn test_part1() { + assert_eq!(part1(TEST_INPUT), 0) + } + + #[test] + fn test_part2() { + assert_eq!(part2(TEST_INPUT), 0) + } +} diff --git a/2022/rust/src/day17.rs b/2022/rust/src/day17.rs new file mode 100644 index 0000000..bc0a3ce --- /dev/null +++ b/2022/rust/src/day17.rs @@ -0,0 +1,32 @@ +mod common; + +fn main() { + let input = common::day_input(panic!("PUT THE CORRECT DAY NUMBER HERE")); + println!("Part 1: {}", part1(&input)); + println!("Part 2: {}", part2(&input)); +} + +fn part1(input: &str) -> i32 { + 0 +} + +fn part2(input: &str) -> i32 { + 0 +} + +#[cfg(test)] +mod tests { + use super::*; + + const TEST_INPUT: &str = ""; + + #[test] + fn test_part1() { + assert_eq!(part1(TEST_INPUT), 0) + } + + #[test] + fn test_part2() { + assert_eq!(part2(TEST_INPUT), 0) + } +} diff --git a/2022/rust/src/day18.rs b/2022/rust/src/day18.rs new file mode 100644 index 0000000..bc0a3ce --- /dev/null +++ b/2022/rust/src/day18.rs @@ -0,0 +1,32 @@ +mod common; + +fn main() { + let input = common::day_input(panic!("PUT THE CORRECT DAY NUMBER HERE")); + println!("Part 1: {}", part1(&input)); + println!("Part 2: {}", part2(&input)); +} + +fn part1(input: &str) -> i32 { + 0 +} + +fn part2(input: &str) -> i32 { + 0 +} + +#[cfg(test)] +mod tests { + use super::*; + + const TEST_INPUT: &str = ""; + + #[test] + fn test_part1() { + assert_eq!(part1(TEST_INPUT), 0) + } + + #[test] + fn test_part2() { + assert_eq!(part2(TEST_INPUT), 0) + } +} diff --git a/2022/rust/src/day19.rs b/2022/rust/src/day19.rs new file mode 100644 index 0000000..bc0a3ce --- /dev/null +++ b/2022/rust/src/day19.rs @@ -0,0 +1,32 @@ +mod common; + +fn main() { + let input = common::day_input(panic!("PUT THE CORRECT DAY NUMBER HERE")); + println!("Part 1: {}", part1(&input)); + println!("Part 2: {}", part2(&input)); +} + +fn part1(input: &str) -> i32 { + 0 +} + +fn part2(input: &str) -> i32 { + 0 +} + +#[cfg(test)] +mod tests { + use super::*; + + const TEST_INPUT: &str = ""; + + #[test] + fn test_part1() { + assert_eq!(part1(TEST_INPUT), 0) + } + + #[test] + fn test_part2() { + assert_eq!(part2(TEST_INPUT), 0) + } +} diff --git a/2022/rust/src/day20.rs b/2022/rust/src/day20.rs new file mode 100644 index 0000000..bc0a3ce --- /dev/null +++ b/2022/rust/src/day20.rs @@ -0,0 +1,32 @@ +mod common; + +fn main() { + let input = common::day_input(panic!("PUT THE CORRECT DAY NUMBER HERE")); + println!("Part 1: {}", part1(&input)); + println!("Part 2: {}", part2(&input)); +} + +fn part1(input: &str) -> i32 { + 0 +} + +fn part2(input: &str) -> i32 { + 0 +} + +#[cfg(test)] +mod tests { + use super::*; + + const TEST_INPUT: &str = ""; + + #[test] + fn test_part1() { + assert_eq!(part1(TEST_INPUT), 0) + } + + #[test] + fn test_part2() { + assert_eq!(part2(TEST_INPUT), 0) + } +} diff --git a/2022/rust/src/day21.rs b/2022/rust/src/day21.rs new file mode 100644 index 0000000..bc0a3ce --- /dev/null +++ b/2022/rust/src/day21.rs @@ -0,0 +1,32 @@ +mod common; + +fn main() { + let input = common::day_input(panic!("PUT THE CORRECT DAY NUMBER HERE")); + println!("Part 1: {}", part1(&input)); + println!("Part 2: {}", part2(&input)); +} + +fn part1(input: &str) -> i32 { + 0 +} + +fn part2(input: &str) -> i32 { + 0 +} + +#[cfg(test)] +mod tests { + use super::*; + + const TEST_INPUT: &str = ""; + + #[test] + fn test_part1() { + assert_eq!(part1(TEST_INPUT), 0) + } + + #[test] + fn test_part2() { + assert_eq!(part2(TEST_INPUT), 0) + } +} diff --git a/2022/rust/src/day22.rs b/2022/rust/src/day22.rs new file mode 100644 index 0000000..bc0a3ce --- /dev/null +++ b/2022/rust/src/day22.rs @@ -0,0 +1,32 @@ +mod common; + +fn main() { + let input = common::day_input(panic!("PUT THE CORRECT DAY NUMBER HERE")); + println!("Part 1: {}", part1(&input)); + println!("Part 2: {}", part2(&input)); +} + +fn part1(input: &str) -> i32 { + 0 +} + +fn part2(input: &str) -> i32 { + 0 +} + +#[cfg(test)] +mod tests { + use super::*; + + const TEST_INPUT: &str = ""; + + #[test] + fn test_part1() { + assert_eq!(part1(TEST_INPUT), 0) + } + + #[test] + fn test_part2() { + assert_eq!(part2(TEST_INPUT), 0) + } +} diff --git a/2022/rust/src/day23.rs b/2022/rust/src/day23.rs new file mode 100644 index 0000000..bc0a3ce --- /dev/null +++ b/2022/rust/src/day23.rs @@ -0,0 +1,32 @@ +mod common; + +fn main() { + let input = common::day_input(panic!("PUT THE CORRECT DAY NUMBER HERE")); + println!("Part 1: {}", part1(&input)); + println!("Part 2: {}", part2(&input)); +} + +fn part1(input: &str) -> i32 { + 0 +} + +fn part2(input: &str) -> i32 { + 0 +} + +#[cfg(test)] +mod tests { + use super::*; + + const TEST_INPUT: &str = ""; + + #[test] + fn test_part1() { + assert_eq!(part1(TEST_INPUT), 0) + } + + #[test] + fn test_part2() { + assert_eq!(part2(TEST_INPUT), 0) + } +} diff --git a/2022/rust/src/day24.rs b/2022/rust/src/day24.rs new file mode 100644 index 0000000..bc0a3ce --- /dev/null +++ b/2022/rust/src/day24.rs @@ -0,0 +1,32 @@ +mod common; + +fn main() { + let input = common::day_input(panic!("PUT THE CORRECT DAY NUMBER HERE")); + println!("Part 1: {}", part1(&input)); + println!("Part 2: {}", part2(&input)); +} + +fn part1(input: &str) -> i32 { + 0 +} + +fn part2(input: &str) -> i32 { + 0 +} + +#[cfg(test)] +mod tests { + use super::*; + + const TEST_INPUT: &str = ""; + + #[test] + fn test_part1() { + assert_eq!(part1(TEST_INPUT), 0) + } + + #[test] + fn test_part2() { + assert_eq!(part2(TEST_INPUT), 0) + } +} diff --git a/2022/rust/src/day25.rs b/2022/rust/src/day25.rs new file mode 100644 index 0000000..bc0a3ce --- /dev/null +++ b/2022/rust/src/day25.rs @@ -0,0 +1,32 @@ +mod common; + +fn main() { + let input = common::day_input(panic!("PUT THE CORRECT DAY NUMBER HERE")); + println!("Part 1: {}", part1(&input)); + println!("Part 2: {}", part2(&input)); +} + +fn part1(input: &str) -> i32 { + 0 +} + +fn part2(input: &str) -> i32 { + 0 +} + +#[cfg(test)] +mod tests { + use super::*; + + const TEST_INPUT: &str = ""; + + #[test] + fn test_part1() { + assert_eq!(part1(TEST_INPUT), 0) + } + + #[test] + fn test_part2() { + assert_eq!(part2(TEST_INPUT), 0) + } +} diff --git a/2022/rust/src/day5.rs b/2022/rust/src/day5.rs new file mode 100644 index 0000000..bc0a3ce --- /dev/null +++ b/2022/rust/src/day5.rs @@ -0,0 +1,32 @@ +mod common; + +fn main() { + let input = common::day_input(panic!("PUT THE CORRECT DAY NUMBER HERE")); + println!("Part 1: {}", part1(&input)); + println!("Part 2: {}", part2(&input)); +} + +fn part1(input: &str) -> i32 { + 0 +} + +fn part2(input: &str) -> i32 { + 0 +} + +#[cfg(test)] +mod tests { + use super::*; + + const TEST_INPUT: &str = ""; + + #[test] + fn test_part1() { + assert_eq!(part1(TEST_INPUT), 0) + } + + #[test] + fn test_part2() { + assert_eq!(part2(TEST_INPUT), 0) + } +} diff --git a/2022/rust/src/day6.rs b/2022/rust/src/day6.rs new file mode 100644 index 0000000..bc0a3ce --- /dev/null +++ b/2022/rust/src/day6.rs @@ -0,0 +1,32 @@ +mod common; + +fn main() { + let input = common::day_input(panic!("PUT THE CORRECT DAY NUMBER HERE")); + println!("Part 1: {}", part1(&input)); + println!("Part 2: {}", part2(&input)); +} + +fn part1(input: &str) -> i32 { + 0 +} + +fn part2(input: &str) -> i32 { + 0 +} + +#[cfg(test)] +mod tests { + use super::*; + + const TEST_INPUT: &str = ""; + + #[test] + fn test_part1() { + assert_eq!(part1(TEST_INPUT), 0) + } + + #[test] + fn test_part2() { + assert_eq!(part2(TEST_INPUT), 0) + } +} diff --git a/2022/rust/src/day7.rs b/2022/rust/src/day7.rs new file mode 100644 index 0000000..bc0a3ce --- /dev/null +++ b/2022/rust/src/day7.rs @@ -0,0 +1,32 @@ +mod common; + +fn main() { + let input = common::day_input(panic!("PUT THE CORRECT DAY NUMBER HERE")); + println!("Part 1: {}", part1(&input)); + println!("Part 2: {}", part2(&input)); +} + +fn part1(input: &str) -> i32 { + 0 +} + +fn part2(input: &str) -> i32 { + 0 +} + +#[cfg(test)] +mod tests { + use super::*; + + const TEST_INPUT: &str = ""; + + #[test] + fn test_part1() { + assert_eq!(part1(TEST_INPUT), 0) + } + + #[test] + fn test_part2() { + assert_eq!(part2(TEST_INPUT), 0) + } +} diff --git a/2022/rust/src/day8.rs b/2022/rust/src/day8.rs new file mode 100644 index 0000000..bc0a3ce --- /dev/null +++ b/2022/rust/src/day8.rs @@ -0,0 +1,32 @@ +mod common; + +fn main() { + let input = common::day_input(panic!("PUT THE CORRECT DAY NUMBER HERE")); + println!("Part 1: {}", part1(&input)); + println!("Part 2: {}", part2(&input)); +} + +fn part1(input: &str) -> i32 { + 0 +} + +fn part2(input: &str) -> i32 { + 0 +} + +#[cfg(test)] +mod tests { + use super::*; + + const TEST_INPUT: &str = ""; + + #[test] + fn test_part1() { + assert_eq!(part1(TEST_INPUT), 0) + } + + #[test] + fn test_part2() { + assert_eq!(part2(TEST_INPUT), 0) + } +} diff --git a/2022/rust/src/day9.rs b/2022/rust/src/day9.rs new file mode 100644 index 0000000..bc0a3ce --- /dev/null +++ b/2022/rust/src/day9.rs @@ -0,0 +1,32 @@ +mod common; + +fn main() { + let input = common::day_input(panic!("PUT THE CORRECT DAY NUMBER HERE")); + println!("Part 1: {}", part1(&input)); + println!("Part 2: {}", part2(&input)); +} + +fn part1(input: &str) -> i32 { + 0 +} + +fn part2(input: &str) -> i32 { + 0 +} + +#[cfg(test)] +mod tests { + use super::*; + + const TEST_INPUT: &str = ""; + + #[test] + fn test_part1() { + assert_eq!(part1(TEST_INPUT), 0) + } + + #[test] + fn test_part2() { + assert_eq!(part2(TEST_INPUT), 0) + } +}