Add Rust & Python day 4

main
Bram 2024-12-04 13:42:17 +00:00
parent f4a6aae550
commit ee4e8eccfb
9 changed files with 303 additions and 1 deletions

140
inputs/04.txt Normal file
View File

@ -0,0 +1,140 @@
MAMAMASXXXSAMXSSSSSXMXMAMMSXMASAMXMXSSXMXXXXMSMSSMXXSAXMMSSSMSXMMXSMMMMSSMMMAMMMMSMMSXMAXMASMMSXASXSAMXXAAMXMXMAMXMAAXMASXSMXSSSSSSSSXMXSAMX
MSMMMMSXAAAMSMMAAMMMMAMASXMASAMMSXAXXMAMSMMMMXAMAMXAMMXSAAAAASASMASXAAMXAAXSAMAMMAAXXAMXMMSMMXMAMSAMXMMMSMMAXXXMXSMSMSMASMSMAMAAAAAAXXSASAAX
XAAXMAMMSMMMSAMMMMXAMAMXAAXAMXSAMAMXMSXMAASASMSMAMMXXAAMXMSMMSAMMAMXMXSXSMMMASMXSSMMMAMAAMAAASXSAMXMAXSAAAMSSSMMAAAASAMXXAMMAMAMMMMMMMMASMMS
SSXMMAXAAXMASMMXSXSMSSSSSXMSSMMXSAMXXAAXSMSASAMAMXXMMMXXAMXXXMXMMSXMSAXMAMXSXMXAAMXSASMMSXXMMAAXMXXSAXMMMSAAAXAASMMMSXSSMSMSASXSMXAXASMMMMAX
XXASMSSSMMMMSAMAMAXMAAMAMXMAAXAAMMMMMSSMAAMMMMMSSSSXSAASMSAXSAMXXXAAMAMSAMXSXAMMMMASAMAXMMMSAMXMSAMASXAAAMMMMMAMMAXXXAAAAMASASXAMSMSMSXXAMXM
MSXMAAAAXMSAMAMXSAMAMSMSMMXSMMMXSAXAAAXXMMMXMXMAAXAAMMXSAAMSMAMSAMMMMAMSASAMMSMSAMXSASXMSAAAAXSXMASAAXSMXMMASMMSSSMXMMMSSMAMAMMMMSAAXMAMSXSA
ASMMMMAMAXMASMMMMASMXAXAMXAAAXMASXSMSXSSXSAMXAMMSMMMMSMMXMMMXAMXXSAMSSMXAMMSMXASMSASAMXXMMSSSMMXSXMASMXMSMSAS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MSMMXAXAMAMXXASMS
SMXSASAMSSMMSSMMMMAMSXMASMSMSMSMMMMMMMAASMMMXMASMMMSXSAMAXSASAXMAAASXSSSMSMMMSAMSAMMMAMXMXMASAMMSSSMMMMMMSSMSAMXMMXSSXSMSXSAAXMMSMMMSSMSMMAA
AAASMSASAXAAAXAAXSASXAXMASAXMAMAAAXAAMSMMXASAMMSAASAAMASAMSAMXMASXMSAAASAMXAASAMMAAXMXMASAMXMAAXMAMAAAAAMMAMXAAAAXAAXAMAMAMSSMXXMASAAAMMAMSM
MMMSAMXMXSXMSSMMMSXSMSMAXSSMMXMSSSSMSMMXXSSSMSXSMMMXSSMMMMMAMMMMXSMMMMMMSMSMMSMMSAMXAXSXSMXXASXXMASXSSSSSSXMSSMASMSSMMMMMXMAXMSMSSMMSSMSAMXX

View File

@ -4,3 +4,5 @@ import src.day_02.part_1
import src.day_02.part_2
import src.day_03.part_1
import src.day_03.part_2
import src.day_04.part_1
import src.day_04.part_2

2
src/day_04/mod.rs Normal file
View File

@ -0,0 +1,2 @@
pub mod part_1;
pub mod part_2;

37
src/day_04/part_1.py Normal file
View File

@ -0,0 +1,37 @@
def main():
lines = [ line.strip() for line in open('inputs/04.txt') ]
total = 0
rows = len(lines)
cols = len(lines[0])
for x in range(cols):
for y in range(rows):
if lines[y][x] == 'X':
total += inspect_grid(lines, cols, rows, y, x)
print(f"Day 04 part 1: {total}")
def inspect_grid(grid, cols, rows, y, x) -> int:
total = 0
for dx in [-1, 0, 1]:
for dy in [-1, 0, 1]:
if dx == dy == 0:
continue
S_x, S_y = x + 3 * dx, y + 3 * dy
if S_x < 0 or S_x >= cols or S_y < 0 or S_y >= rows:
continue
m = grid[y+dy][x+dx] == 'M'
a = grid[y+2*dy][x+2*dx] == 'A'
s = grid[y+3*dy][x+3*dx] == 'S'
if m and a and s:
total += 1
return total
main()

47
src/day_04/part_1.rs Normal file
View File

@ -0,0 +1,47 @@
pub fn answer(s : &str) -> u32 {
let grid : Vec<Vec<char>> = s.split("\n")
.map(|s| s.chars().collect())
.collect();
let rows : i32 = grid.len().try_into().unwrap();
let cols : i32 = grid[0].len().try_into().unwrap();
let mut total : u32 = 0;
for y in 0..rows {
for x in 0..cols {
if grid[y as usize][x as usize] == 'X' {
total = total + inspect_location(&grid, x, y, rows, cols)
}
}
};
total
}
fn inspect_location(grid : &Vec<Vec<char>>, x : i32, y : i32, rows : i32, cols : i32) -> u32 {
let mut total = 0;
for dx in -1..=1 {
for dy in -1..=1 {
if dx == 0 && dy == 0 {
continue;
}
let (s_x, s_y) = ( x + 3 * dx, y + 3 * dy );
if s_x < 0 || s_x >= rows || s_y < 0 || s_y >= cols {
continue;
}
let m = grid[(y + 1 * dy) as usize][(x + 1 * dx) as usize];
let a = grid[(y + 2 * dy) as usize][(x + 2 * dx) as usize];
let s = grid[(y + 3 * dy) as usize][(x + 3 * dx) as usize];
if m == 'M' && a == 'A' && s == 'S' {
total = total + 1;
}
}
};
total
}

30
src/day_04/part_2.py Normal file
View File

@ -0,0 +1,30 @@
def main():
lines = [ line.strip() for line in open('inputs/04.txt') ]
total = 0
rows = len(lines)
cols = len(lines[0])
for x in range(1, cols-1):
for y in range(1, rows-1):
if lines[y][x] == 'A':
total += inspect_grid(lines, y, x)
print(f"Day 04 part 2: {total}")
def inspect_grid(grid, y, x):
c1 = grid[y-1][x-1]
c2 = grid[y-1][x+1]
c3 = grid[y+1][x-1]
c4 = grid[y+1][x+1]
horizontal = c1 == c2 and c3 == c4 and c1 != c4
vertical = c1 == c3 and c2 == c4 and c1 != c4
correct_letters = (c1 == 'M' and c4 == 'S') or (c1 == 'S' and c4 == 'M')
if correct_letters and (horizontal or vertical):
return 1
else:
return 0
main()

36
src/day_04/part_2.rs Normal file
View File

@ -0,0 +1,36 @@
pub fn answer(s : &str) -> u32 {
let grid : Vec<Vec<char>> = s.split("\n")
.map(|s| s.chars().collect())
.collect();
let rows = grid.len();
let cols = grid[0].len();
let mut total : u32 = 0;
for y in 1..rows-1 {
for x in 1..cols-1 {
if grid[y as usize][x as usize] == 'A' {
total = total + inspect_location(&grid, x, y)
}
}
};
total
}
fn inspect_location(grid : &Vec<Vec<char>>, x : usize, y : usize) -> u32 {
let c1 = grid[y-1][x-1];
let c2 = grid[y-1][x+1];
let c3 = grid[y+1][x-1];
let c4 = grid[y+1][x+1];
let horizontal = c1 == c2 && c3 == c4 && c1 != c3;
let vertical = c1 == c3 && c2 == c4 && c1 != c2;
let letters_match = (c1 == 'M' && c4 == 'S') || (c1 == 'S' && c4 == 'M');
if letters_match && (horizontal || vertical) {
1
} else {
0
}
}

View File

@ -2,6 +2,7 @@ mod utils;
mod day_01;
mod day_02;
mod day_03;
mod day_04;
pub fn day_01() {
let s : String = utils::read_from_file("inputs/01.txt");
@ -19,4 +20,10 @@ pub fn day_03() {
let s : String = utils::read_from_file("inputs/03.txt");
println!("Day 03 part 1: {}", day_03::part_1::answer(s.as_str()));
println!("Day 03 part 2: {}", day_03::part_2::answer(s.as_str()));
}
}
pub fn day_04() {
let s : String = utils::read_from_file("inputs/04.txt");
println!("Day 04 part 1: {}", day_04::part_1::answer(s.as_str()));
println!("Day 04 part 2: {}", day_04::part_2::answer(s.as_str()));
}

View File

@ -2,4 +2,5 @@ fn main() {
aoc_2024::day_01();
aoc_2024::day_02();
aoc_2024::day_03();
aoc_2024::day_04();
}