Scaffold remaining days

This commit is contained in:
Daniel Flanagan 2022-12-03 22:46:42 -06:00
parent a9429f5ab6
commit 4bacc819a6
Signed by: lytedev
GPG key ID: 5B2020A0F9921EF4
22 changed files with 725 additions and 1 deletions

View file

@ -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 ->
<<a::binary-size(div(byte_size(s), 2)), b::binary>> = 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()
```
<!-- livebook:{"output":true} -->
```
7597
2607
```
<!-- livebook:{"output":true} -->
```
2607
```

32
2022/rust/src/day10.rs Normal file
View file

@ -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)
}
}

32
2022/rust/src/day11.rs Normal file
View file

@ -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)
}
}

32
2022/rust/src/day12.rs Normal file
View file

@ -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)
}
}

32
2022/rust/src/day13.rs Normal file
View file

@ -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)
}
}

32
2022/rust/src/day14.rs Normal file
View file

@ -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)
}
}

32
2022/rust/src/day15.rs Normal file
View file

@ -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)
}
}

32
2022/rust/src/day16.rs Normal file
View file

@ -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)
}
}

32
2022/rust/src/day17.rs Normal file
View file

@ -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)
}
}

32
2022/rust/src/day18.rs Normal file
View file

@ -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)
}
}

32
2022/rust/src/day19.rs Normal file
View file

@ -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)
}
}

32
2022/rust/src/day20.rs Normal file
View file

@ -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)
}
}

32
2022/rust/src/day21.rs Normal file
View file

@ -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)
}
}

32
2022/rust/src/day22.rs Normal file
View file

@ -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)
}
}

32
2022/rust/src/day23.rs Normal file
View file

@ -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)
}
}

32
2022/rust/src/day24.rs Normal file
View file

@ -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)
}
}

32
2022/rust/src/day25.rs Normal file
View file

@ -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)
}
}

32
2022/rust/src/day5.rs Normal file
View file

@ -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)
}
}

32
2022/rust/src/day6.rs Normal file
View file

@ -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)
}
}

32
2022/rust/src/day7.rs Normal file
View file

@ -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)
}
}

32
2022/rust/src/day8.rs Normal file
View file

@ -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)
}
}

32
2022/rust/src/day9.rs Normal file
View file

@ -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)
}
}