Compare commits

..

No commits in common. "fe3b71908e110dbd758fa3cf05454ab9a5d0c09c" and "7a0c4751ebd87f9a4e1d331a2b663bd62b0bb75b" have entirely different histories.

View file

@ -1,35 +1,14 @@
const std = @import("std");
pub const title = "Day 04: Printing Department";
pub const title = "Day 04";
pub fn run(_: std.mem.Allocator) !void {
const initial_input = @embedFile("./input/day04.txt");
//const initial_input =
// \\..@@.@@@@.
// \\@@@.@.@.@@
// \\@@@@@.@.@@
// \\@.@@@@..@.
// \\@@.@@@@.@@
// \\.@@@@@@@.@
// \\.@.@.@.@@@
// \\@.@@@.@@@@
// \\.@@@@@@@@.
// \\@.@.@@@.@.
// ;
const input: []u8 = @constCast(initial_input);
const input = @embedFile("./input/day04.txt");
var lines = std.mem.tokenizeScalar(u8, input, '\n');
var accumulator: u32 = 0;
while (true) {
std.debug.print("{s}\n", .{input});
var rolls_removed: u32 = 0;
var lines = std.mem.tokenizeScalar(u8, input, '\n');
var previous_line: ?[]const u8 = null;
var line_index: usize = 0;
while (lines.next()) |line| {
const next_line = lines.peek();
@ -57,21 +36,11 @@ pub fn run(_: std.mem.Allocator) !void {
}
if (rolls < 4) {
input[(line_index * (line.len + 1)) + i] = 'x';
rolls_removed += 1;
accumulator += 1;
}
}
previous_line = line;
line_index += 1;
}
std.debug.print("removed {d} rolls\n", .{rolls_removed});
if (rolls_removed > 0) {
accumulator += rolls_removed;
} else {
break;
}
}
var buffer: [8]u8 = undefined;