2024: Day 4 completed

This commit is contained in:
Andrew Scott 2024-12-12 00:05:49 -05:00
parent a27a6df8b4
commit 7dc3712207
Signed by: a
GPG key ID: 7CD5A5977E4931C1
2 changed files with 262 additions and 0 deletions

140
2024/data/day4.txt Normal file
View file

@ -0,0 +1,140 @@
MMSMXMSASXMXAXMAXSASXXXMASAMXSMMMXMMXMXMASMXMASMSMXSSXMASXSMMSASMSAXAMXMAMMMSAMXXXMAMSMXMMMXMASXMAXXMMMXMMSAMXAMMSMSSMSMMMSMMXSXXAXMXSAXMASX
XAXMASMXMASASXSXAMAMXMXMAXAMXSASAMXMAMAMSAMSSXMMAXASXAMAMSMAXMXMASMSASASASAAMAMXSMSMSAXAAXXAMSSMXMXSMAMXXAXAXXASXAMAAXAAXXMAXAXXMMSSMSSXSASA
XMASXXXASAMAMASMMMAMMSASXSXMASAMMAXSAXXXMASXMASMSMMMMXMAXAXXMSAMXMAAXSASASMXSAMAAAAXSASMMMMMSAXMASAMSAMSMMSAMSAMAMMXSMSXMASXMASAASAAXMAMMAMM
SSMSMSSXMMMAMSMAXMAXXMAMMAMSXMSMMMXMAMSXSSMXSAMXXAASXMSMSMSMMSXSAMMMMMAMXMXAMASXMSMMMXMAAAXMMMSMAMAMMMMAAXMAMSAMXXXMAMAASXMAAXXMXMSMMMSMMAMX
XXAXAAAMMSSMMXASXSMSSMAMSAMXAXXXASMMSMSASAMXMASMSXMXAAXXAAAAASASAMAXSMSMSSMSSMAAXAXAMXMMMSXXAXAMSSSMMSSMSMSAMSMMSMXMMXSMSASXSXMMSMAMAAMAMASX
MMMMSMMAAAAMASXMAAXAAMSMXAMSAMXSMXAAAAMMMAMASMMMASXSMMSSSSSSMMMMMSAMSXASAAAAAMMXSXSMXSSXSAXAMMMSMAXAAXAMXAASAMXMXAMXMAMXSAMMMXXAAMXMMXSAMAAX
XAAAXAXMMSSMASAMXMMSSMMASMMSASXMXAXMMMMAMMSAMAAMAMXAXMMAXAMAMXSAMMMMMMMMSSMSMMXMAM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MAXMMSSMAMXXXAXMAMAMXAXAAAAAXAMMXXXMAMAMAXAMMAMASXMAAXAXSXXXAXMAXSAAXXAXAAASMMSXSASXSSXSMSMSMMXAMXAAXXMXAMXSSMMMAAMMMSXMMXSSMASX
XMSAAMSMSSSSMSMSAAAXXSMMMSMXAMMSMAMSMMSSSMSMSAMXSMSMSMASMMMAMMMSMMMSXSMMSSMMMMMMSMMMMSMMAAXAMAMAMAASAAXMAXSASXXSMAMSMMAAAASXSSMMMSAXAASASAMM
SXMMSMAAAAAMAAAMMSMMSXAAAAASMSAXMAMAAMAAAAAASMAAXAXAXSAMAAMASXXMASXSAMXAAAAAXXSAMXSAMXXMMMMAMAMAMMSMSMMSAMSAMAXXMXMASMXSSMMMXAAAASMMMSSMMMSA
XXXXXXMSMMMMMMSMXAXMASXMSXMAAMMSSMSSSMXSMMMMMMSAMSMMMMMSSMSXSASXMMSMAMMMSSMMAMXXMASXSAXMAMSXSXSXSXXMAMXMXXMMMAMXAXMAMSAAXMXMASXMMSXXMAMXXMAX

122
2024/src/day4.zig Normal file
View file

@ -0,0 +1,122 @@
const std = @import("std");
const util = @import("util.zig");
const log = util.log;
const Directions = enum { e, w, n, s, ne, nw, se, sw, done };
fn toMatrix(allocator: std.mem.Allocator) !std.ArrayList([]const u8) {
const input = try util.readAllInput(4, allocator);
errdefer allocator.free(input);
const mat: std.ArrayList([]const u8) = try util.inputTo2x2(u8, allocator, input, '\n');
errdefer mat.deinit();
return mat;
}
fn isValidPoint(x: i16, y: i16, max: [2]u8) bool {
return 0 <= x and x <= max[0] and 0 <= y and y <= max[1];
}
fn isXmas(matrix: [][]const u8, start: [2]u8, max: [2]u8, delta: [2]i8) !bool {
for (1..4) |i| {
const step: i8 = @intCast(i);
const x = try std.math.add(i16, @intCast(start[0]), delta[0] * step);
const y = try std.math.add(i16, @intCast(start[1]), delta[1] * step);
if (!isValidPoint(x, y, max)) {
return false;
}
const ux: u8 = @intCast(x);
const uy: u8 = @intCast(y);
if ((i == 1 and matrix[ux][uy] != 'M') or
(i == 2 and matrix[ux][uy] != 'A') or
(i == 3 and matrix[ux][uy] != 'S'))
{
return false;
}
}
return true;
}
fn part1(matrix: [][]const u8, start: [2]u8, max: [2]u8) !u8 {
var result: u8 = 0;
var direction: Directions = .e;
var delta: [2]i8 = .{ 0, 0 };
while (direction != .done) {
const new_direction = @intFromEnum(direction) + 1;
defer direction = @enumFromInt(new_direction);
switch (direction) {
.e => delta = .{ 0, 1 },
.w => delta = .{ 0, -1 },
.n => delta = .{ -1, 0 },
.s => delta = .{ 1, 0 },
.ne => delta = .{ -1, 1 },
.nw => delta = .{ -1, -1 },
.se => delta = .{ 1, 1 },
.sw => delta = .{ 1, -1 },
else => unreachable,
}
if (try isXmas(matrix, start, max, delta))
result += 1;
}
return result;
}
fn part2(matrix: [][]const u8, start: [2]u8, max: [2]u8) !bool {
const nw_pt = .{ try std.math.add(i16, @intCast(start[0]), -1), try std.math.add(i16, @intCast(start[1]), -1) };
const ne_pt = .{ try std.math.add(i16, @intCast(start[0]), -1), try std.math.add(i16, @intCast(start[1]), 1) };
const sw_pt = .{ try std.math.add(i16, @intCast(start[0]), 1), try std.math.add(i16, @intCast(start[1]), -1) };
const se_pt = .{ try std.math.add(i16, @intCast(start[0]), 1), try std.math.add(i16, @intCast(start[1]), 1) };
if (!isValidPoint(nw_pt[0], nw_pt[1], max) or
!isValidPoint(ne_pt[0], ne_pt[1], max) or
!isValidPoint(sw_pt[0], sw_pt[1], max) or
!isValidPoint(se_pt[0], se_pt[1], max))
{
return false;
}
const nw_ch = matrix[start[0] - 1][start[1] - 1];
const ne_ch = matrix[start[0] - 1][start[1] + 1];
const sw_ch = matrix[start[0] + 1][start[1] - 1];
const se_ch = matrix[start[0] + 1][start[1] + 1];
if (!(nw_ch == 'M' and ne_ch == 'M' and sw_ch == 'S' and se_ch == 'S') and
!(nw_ch == 'S' and ne_ch == 'S' and sw_ch == 'M' and se_ch == 'M') and
!(nw_ch == 'M' and ne_ch == 'S' and sw_ch == 'M' and se_ch == 'S') and
!(nw_ch == 'S' and ne_ch == 'M' and sw_ch == 'S' and se_ch == 'M'))
{
return false;
}
return true;
}
pub fn main() !void {
const allocator = util.alloc;
const mat = try toMatrix(allocator);
defer mat.deinit();
const max: [2]u8 = .{ @intCast(mat.items[0].len - 1), @intCast(mat.items.len - 1) };
var p1: u16 = 0;
var p2: u16 = 0;
for (mat.items, 0..) |_, row| {
for (mat.items[row], 0..) |_, col| {
const start: [2]u8 = .{ @intCast(row), @intCast(col) };
if (mat.items[row][col] == 'X')
p1 += try part1(mat.items, start, max);
if (mat.items[row][col] == 'A')
p2 += if (try part2(mat.items, start, max)) 1 else 0;
}
}
log.info("PART 1: {d}", .{p1});
log.info("PART 2: {d}", .{p2});
}