Add solutions for day 4 and 5.1
This commit is contained in:
parent
8e9c34571d
commit
39b7dd0e8b
6 changed files with 1775 additions and 0 deletions
141
inputs/day_4.txt
Normal file
141
inputs/day_4.txt
Normal file
|
@ -0,0 +1,141 @@
|
||||||
|
XMXMAXXSXSSMMMXAMXMMMAMXMAMXAMSAMXSAMXMXMMMAXXMASMSMSAMXMSMMMAMXMXAMMAMMMXMAMMMMMAMMMMSAMXMMAMXAXMXMAMXSXSMMSMMMMSMMXXAMSMSASAXMMMSMMMSMASMM
|
||||||
|
MSMSMSMXMMAASAMXMASMMXSSMSSMSMMXXSAMXMXMXMSMMXMMMAAXXAAAMXSSSMAAXSXSMSASXMMSMMAAMAMXMASMSASASXMASMMSMSAMMASXAXAASAAMAMSXMAXAMAMSAXAAMASMAMAM
|
||||||
|
MAAAAXXAAXXMMMSASASASAAAAAAAAAXSMSAMMMAMAMAAMMMAMMMMMSSXSAMXAMMMMAXSAXAXMMAAASXMMASMMMSXSASAXMSAAXAMAMAXSAMMSMSSSMSMMAAAMMMMMAMMASMSMAXMASAM
|
||||||
|
XMSMSMSASXMAAAMMMAMAMMSMMMMXMSMAASXMASASXMSMMAMXXAMXAMXMMAXSMMMSAMXMAMSMAMSSMMAMSMSASAMAMAMAMAMSAMXMAMXMMASAMXMAXXXAXXSSMXASXXXSAMXXMAXSMXAS
|
||||||
|
MMAMXXXAAAMMMSSSMMMXMAXXSXXXSAAMMMXMXSAXMAXASMSMXAMXSSXMSSMXXSXMAXSMXMAMSMAMAMMMAXSMMAMAMAMMMSMMXXASASXXSAMMSMMAMXSXMAMAXXXSXMXAAXXXSAMSMSMM
|
||||||
|
ASMXMSMMMXMAAAMAASMXSXSASXMMSASMMMXSAMXMMMSAMMAMMMMMMAAXAMXSMMASMMXMMSMMAMASXMXMAXXASMMXXXXAMAXSSSMSASMMMASASAMAMXMASMSXSMSMMAXMXSMMMASXAAAX
|
||||||
|
MXAASXSXAAXSMSSMXMMAMAMAMMMASAMXXAAMXMAAAXMX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MASAMASMMMAMSMMAXMAAAAMAXAMMMSSXMXAAAMMSSXMASXSXMAMXMMMAMAMASASMMSMAAXMAXAXXMMSAAXSMMMSMSMMSXXASXSMSSMSSXXMMMAAXMXMXA
|
||||||
|
MMMXAMXXAMASXSAMXSSMAMXMAMAMAXAASAXMAMXMSMSSSSSMXSAXMAXSAMXMMAMXMAXMAMXMMSMMASAMXSAMXSAAAMMMMSMSSSMAMMMMXMASAMASAMMMSMSAXMAXMAMAMMAMMSMMSMMM
|
||||||
|
AAASXMASXSMMAMMMXAXMASAMASAMXSSMSMXSAMMAXAAAAAAAASAXSAXMAXXSMXSAMSAXAXXSAMASMSXSAMXSAMXSXSMXXXXAAAXSMXXXASMMSAASMMAAAAMMMMASMAMAXSAXSAASAAAX
|
||||||
|
SXXAMMAXMAMMXMXMASASMSASMSXSAMAMXAMSAMXSSMASMSMMMXSAMXSSMMAXSXSASXMSAMXXMMMAMXXMXXSAMXMMMXXMASMMSMMMMSAMXSMAXMASXSMSSSMXXAMMXASMXAMXSASXSSMS
|
||||||
|
|
1353
inputs/day_5.txt
Normal file
1353
inputs/day_5.txt
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,3 +1,5 @@
|
||||||
|
#![feature(int_roundings)]
|
||||||
|
|
||||||
mod solutions;
|
mod solutions;
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
|
@ -14,6 +16,8 @@ fn main() -> std::io::Result<()> {
|
||||||
Ok(1) => solutions::day_1::run(args)?,
|
Ok(1) => solutions::day_1::run(args)?,
|
||||||
Ok(2) => solutions::day_2::run(args)?,
|
Ok(2) => solutions::day_2::run(args)?,
|
||||||
Ok(3) => solutions::day_3::run(args)?,
|
Ok(3) => solutions::day_3::run(args)?,
|
||||||
|
Ok(4) => solutions::day_4::run(args)?,
|
||||||
|
Ok(5) => solutions::day_5::run(args)?,
|
||||||
Ok(_) => eprintln!("Unknown day. Are you from the future?"),
|
Ok(_) => eprintln!("Unknown day. Are you from the future?"),
|
||||||
Err(_) => eprintln!("Unknown day format. Use integers to specify."),
|
Err(_) => eprintln!("Unknown day format. Use integers to specify."),
|
||||||
}
|
}
|
||||||
|
|
184
src/solutions/day_4.rs
Normal file
184
src/solutions/day_4.rs
Normal file
|
@ -0,0 +1,184 @@
|
||||||
|
use std::env;
|
||||||
|
use std::fs::File;
|
||||||
|
use std::io::{BufRead, BufReader};
|
||||||
|
use std::ops::Add;
|
||||||
|
|
||||||
|
enum State {
|
||||||
|
ExpectM,
|
||||||
|
ExpectA,
|
||||||
|
ExpectS,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
enum Dir {
|
||||||
|
/// Diagonal up left: x - 1, y - 1
|
||||||
|
DiagUL,
|
||||||
|
/// Up: y - 1
|
||||||
|
Up,
|
||||||
|
/// Diagonal up right: x + 1, y - 1
|
||||||
|
DiagUR,
|
||||||
|
/// Left: x - 1
|
||||||
|
Left,
|
||||||
|
/// Right: x + 1
|
||||||
|
Right,
|
||||||
|
/// Diagonal down right: x - 1, y + 1
|
||||||
|
DiagDL,
|
||||||
|
/// Down: y + 1
|
||||||
|
Down,
|
||||||
|
/// Diagonal down right: x + 1, y + 1
|
||||||
|
DiagDR,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
|
struct Point {
|
||||||
|
x: usize,
|
||||||
|
y: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn check_direction(map: &Vec<Vec<char>>, state: State, pt: Point, direction: Dir) -> bool {
|
||||||
|
let next_pt = pt + direction;
|
||||||
|
|
||||||
|
let c = map[next_pt.x][next_pt.y];
|
||||||
|
|
||||||
|
match state {
|
||||||
|
State::ExpectM => {
|
||||||
|
if c == 'M' {
|
||||||
|
check_direction(map, State::ExpectA, next_pt, direction)
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
State::ExpectA => {
|
||||||
|
if c == 'A' {
|
||||||
|
check_direction(map, State::ExpectS, next_pt, direction)
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
State::ExpectS => c == 'S',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn check_all(map: &Vec<Vec<char>>, x: usize, y: usize) -> u64 {
|
||||||
|
let pt = Point { x, y };
|
||||||
|
let mut sum = 0;
|
||||||
|
if x >= 3 {
|
||||||
|
if y >= 3 && check_direction(map, State::ExpectM, pt, Dir::DiagUL) {
|
||||||
|
sum += 1;
|
||||||
|
}
|
||||||
|
if check_direction(map, State::ExpectM, pt, Dir::Left) {
|
||||||
|
sum += 1;
|
||||||
|
}
|
||||||
|
if (y + 3) < map[0].len() && check_direction(map, State::ExpectM, pt, Dir::DiagDL) {
|
||||||
|
sum += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if y >= 3 && check_direction(map, State::ExpectM, pt, Dir::Up) {
|
||||||
|
sum += 1;
|
||||||
|
}
|
||||||
|
if (y + 3) < map[0].len() && check_direction(map, State::ExpectM, pt, Dir::Down) {
|
||||||
|
sum += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x + 3) < map.len() {
|
||||||
|
if y >= 3 && check_direction(map, State::ExpectM, pt, Dir::DiagUR) {
|
||||||
|
sum += 1;
|
||||||
|
}
|
||||||
|
if check_direction(map, State::ExpectM, pt, Dir::Right) {
|
||||||
|
sum += 1;
|
||||||
|
}
|
||||||
|
if (y + 3) < map[0].len() && check_direction(map, State::ExpectM, pt, Dir::DiagDR) {
|
||||||
|
sum += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn check_day_2(map: &Vec<Vec<char>>, x: usize, y: usize) -> bool {
|
||||||
|
map[x][y] == 'A'
|
||||||
|
&& x >= 1
|
||||||
|
&& y >= 1
|
||||||
|
&& (x + 1) < map.len()
|
||||||
|
&& (y + 1) < map[0].len()
|
||||||
|
&& (map[x - 1][y - 1] == 'M' && map[x + 1][y + 1] == 'S'
|
||||||
|
|| map[x - 1][y - 1] == 'S' && map[x + 1][y + 1] == 'M')
|
||||||
|
&& (map[x - 1][y + 1] == 'M' && map[x + 1][y - 1] == 'S'
|
||||||
|
|| map[x - 1][y + 1] == 'S' && map[x + 1][y - 1] == 'M')
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn run(mut args: env::Args) -> std::io::Result<()> {
|
||||||
|
let filename = args
|
||||||
|
.next()
|
||||||
|
.expect("You must provide a filename as argument");
|
||||||
|
|
||||||
|
let f = File::open(filename)?;
|
||||||
|
let reader = BufReader::new(f);
|
||||||
|
|
||||||
|
let mut sum = 0;
|
||||||
|
let mut sum_2 = 0;
|
||||||
|
let mut map: Vec<Vec<char>> = Vec::new();
|
||||||
|
|
||||||
|
for line in reader.lines() {
|
||||||
|
let l = line.unwrap();
|
||||||
|
if l.is_empty() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
map.push(l.chars().collect());
|
||||||
|
}
|
||||||
|
|
||||||
|
// x: the rows
|
||||||
|
// y: the columns
|
||||||
|
for x in 0..map.len() {
|
||||||
|
for y in 0..map[x].len() {
|
||||||
|
if map[x][y] == 'X' {
|
||||||
|
sum += check_all(&map, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
// part 2
|
||||||
|
if check_day_2(&map, x, y) {
|
||||||
|
sum_2 += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Task 1
|
||||||
|
println!("Number of 'XMAS': {sum}");
|
||||||
|
|
||||||
|
// Task 2
|
||||||
|
println!("Number of 'X-MAS': {sum_2}");
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Add<Dir> for Point {
|
||||||
|
type Output = Self;
|
||||||
|
|
||||||
|
fn add(mut self, other: Dir) -> Self {
|
||||||
|
match other {
|
||||||
|
Dir::Up => self.y -= 1,
|
||||||
|
Dir::Down => self.y += 1,
|
||||||
|
Dir::Left => self.x -= 1,
|
||||||
|
Dir::Right => self.x += 1,
|
||||||
|
Dir::DiagUL => {
|
||||||
|
self.x -= 1;
|
||||||
|
self.y -= 1;
|
||||||
|
}
|
||||||
|
Dir::DiagUR => {
|
||||||
|
self.x += 1;
|
||||||
|
self.y -= 1;
|
||||||
|
}
|
||||||
|
Dir::DiagDL => {
|
||||||
|
self.x -= 1;
|
||||||
|
self.y += 1;
|
||||||
|
}
|
||||||
|
Dir::DiagDR => {
|
||||||
|
self.x += 1;
|
||||||
|
self.y += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
91
src/solutions/day_5.rs
Normal file
91
src/solutions/day_5.rs
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
use std::collections::{HashMap, HashSet};
|
||||||
|
use std::env;
|
||||||
|
use std::fs::File;
|
||||||
|
use std::io::{BufRead, BufReader};
|
||||||
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
enum ParserState {
|
||||||
|
Restrictions,
|
||||||
|
Updates,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Default)]
|
||||||
|
struct NumEntry {
|
||||||
|
pub less_than: HashSet<u8>,
|
||||||
|
pub greater_than: HashSet<u8>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn run(mut args: env::Args) -> std::io::Result<()> {
|
||||||
|
let filename = args
|
||||||
|
.next()
|
||||||
|
.expect("You must provide a filename as argument");
|
||||||
|
|
||||||
|
let f = File::open(filename)?;
|
||||||
|
let reader = BufReader::new(f);
|
||||||
|
|
||||||
|
let mut state = ParserState::Restrictions;
|
||||||
|
let mut ordering: HashMap<u8, NumEntry> = HashMap::new();
|
||||||
|
let mut lists: Vec<Vec<u8>> = Vec::new();
|
||||||
|
|
||||||
|
for line in reader.lines() {
|
||||||
|
let l = line.unwrap();
|
||||||
|
match state {
|
||||||
|
ParserState::Restrictions => {
|
||||||
|
if l.is_empty() {
|
||||||
|
state = ParserState::Updates;
|
||||||
|
} else {
|
||||||
|
let nums: Vec<u8> =
|
||||||
|
l.split("|").map(u8::from_str).map(Result::unwrap).collect();
|
||||||
|
assert!(nums.len() == 2);
|
||||||
|
|
||||||
|
ordering
|
||||||
|
.entry(nums[0])
|
||||||
|
.or_default()
|
||||||
|
.less_than
|
||||||
|
.insert(nums[1]);
|
||||||
|
ordering
|
||||||
|
.entry(nums[1])
|
||||||
|
.or_default()
|
||||||
|
.greater_than
|
||||||
|
.insert(nums[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ParserState::Updates => {
|
||||||
|
if !l.is_empty() {
|
||||||
|
lists.push(l.split(",").map(u8::from_str).map(Result::unwrap).collect());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lists.retain(|v| is_compliant(v, &ordering));
|
||||||
|
|
||||||
|
// Task 1
|
||||||
|
let sum = lists.iter().fold(0, |acc, v| {
|
||||||
|
let idx = v.len().div_floor(2);
|
||||||
|
acc + v[idx] as u32
|
||||||
|
});
|
||||||
|
|
||||||
|
println!("Sum of middle values: {sum}");
|
||||||
|
|
||||||
|
// Task 2
|
||||||
|
// TBD
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_compliant(list: &[u8], ordering: &HashMap<u8, NumEntry>) -> bool {
|
||||||
|
for i in 0..list.len() {
|
||||||
|
// skip numbers that have no associated rules
|
||||||
|
if let Some(entry) = ordering.get(&list[i]) {
|
||||||
|
for j in i..list.len() {
|
||||||
|
if entry.greater_than.contains(&list[j]) {
|
||||||
|
// that's a violation!
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
|
@ -1,4 +1,6 @@
|
||||||
pub mod day_1;
|
pub mod day_1;
|
||||||
pub mod day_2;
|
pub mod day_2;
|
||||||
pub mod day_3;
|
pub mod day_3;
|
||||||
|
pub mod day_4;
|
||||||
|
pub mod day_5;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue