commit bffd1c1d6a3b5f65ba78ca34d77e23b37e3a53a3
parent d7bec1fe5e6d30890a9de21a4bc012c78bb8a226
Author: Louis Burda <quent.burda@gmail.com>
Date: Sat, 5 Dec 2020 10:55:50 +0100
Day 5
Diffstat:
6 files changed, 970 insertions(+), 4 deletions(-)
diff --git a/data/template.zig b/data/template.zig
@@ -3,13 +3,13 @@ const aoc = @import("aoc");
const Entry = u16;
-fn free_entries(allocator: *std.mem.Allocator, entries: std.ArrayList(Entry)) void {
+fn freeEntries(allocator: *std.mem.Allocator, entries: std.ArrayList(Entry)) void {
entries.deinit();
}
fn parse(allocator: *std.mem.Allocator, input: []u8) !std.ArrayList(Entry) {
var entries = std.ArrayList(int).init(allocator);
- errdefer free_entries(allocator, entries);
+ errdefer freeEntries(allocator, entries);
// ...
@@ -18,7 +18,7 @@ fn parse(allocator: *std.mem.Allocator, input: []u8) !std.ArrayList(Entry) {
fn part1(allocator: *std.mem.Allocator, input: []u8, args: [][]u8) !void {
const entries = try parse(allocator, input);
- defer free_entries(allocator, entries);
+ defer freeEntries(allocator, entries);
var answer: u32 = 0;
@@ -27,7 +27,7 @@ fn part1(allocator: *std.mem.Allocator, input: []u8, args: [][]u8) !void {
fn part2(allocator: *std.mem.Allocator, input: []u8, args: [][]u8) !void {
const entries = try parse(allocator, input);
- defer free_entries(allocator, entries);
+ defer freeEntries(allocator, entries);
var answer: u32 = 0;
diff --git a/lib/aoc.zig b/lib/aoc.zig
@@ -1,6 +1,8 @@
const std = @import("std");
pub const input = @import("input.zig");
+pub const Error = error{InvalidInput};
+
const part_type = fn (alloc: *std.mem.Allocator, input: []u8, args: [][]u8) anyerror!void;
pub fn gen_main(comptime part1: part_type, comptime part2: part_type) fn () anyerror!void {
const impl = struct {
diff --git a/src/day5/input b/src/day5/input
@@ -0,0 +1,839 @@
+BFFBFBFLRL
+BFBFBBBLRR
+BFBFBFBLRR
+BFBFFFFRLR
+BBFFBBFRRR
+FBBBFFFRLL
+FFBFBFFLLL
+BBF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FBFBLRL
+FFFFBBFRRL
+FFFFFFBRRL
+FFFBFFBLRL
+BFFBBBBRLL
+FBFBBFBLRL
+BBFFFBBRLL
+FBFFBFBRLL
+FFBBBBBRLL
+FFBFBBFLRL
+FFFFFBBRLR
+FFBBFBFLLL
+FFFFFFBLRR
+BBFFFBFRRR
+FBBFFFBRLL
+FFFFBBBLRL
+BFFFFBFLRR
+BBFBFBFLLR
+BFFFFBFRRL
+BFBBFFFLLL
+FBFFBFBRRR
+BFFFBBFRLL
+BFFFFBBLRL
+FFFBBBFRRL
+FBFFFBFRRR
+FFBBBFFRLL
+BFBFFBBLLL
+BFBFBBBRRL
+BFFFFBFLRL
+FBBFBBBRRR
+FBBFBBFLRL
+FBBBFBBLRR
+FBBBFFBRRR
+BBFFBFBLRR
+FFBBBFFLLR
+BFBFBFFLLL
+FFBBFFBLLR
+FBFBBFFRLL
+FBBFFBFLRL
+FFBFBFBLRR
+FFFBBFBLLR
+FFBBFFBLRL
+BFBBBBBRRR
+BFBFBBFRLL
+FFBBFFFLLR
+FFBBFFBRLL
+FFFBBBFRLR
+BFFFBFFLRR
+BFFBFBBRLR
+BBFFBBBLLL
+FBFBFFBLLR
+FFFBBFFRRR
+BBFBFFFLLR
+FBBFBFFRLL
+FFBBFBBRLL
+FBBBFBFRLL
+BFBBFBBRRL
+BFBFFFFRLL
+BFFFBBBLRR
+FFBBBBBLRR
+BBFFFBBRLR
+BFFBBBFRRL
+BBFFBFBLRL
+BFFBBBBRRL
diff --git a/src/day5/main.zig b/src/day5/main.zig
@@ -0,0 +1,58 @@
+const std = @import("std");
+const aoc = @import("aoc");
+
+const Range = struct { min: u16, max: u16 };
+
+const row_count = 128;
+const col_count = 8;
+
+fn binarySearch(code: []const u8, max: u16, comptime front_id: u8, comptime back_id: u8) !u16 {
+ var possible = Range{ .min = 0, .max = max - 1 };
+ for (code) |b| {
+ _ = switch (b) {
+ front_id => possible.max = @floatToInt(u16, //
+ std.math.floor(@intToFloat(f32, possible.min + possible.max) / 2.0)),
+ back_id => possible.min = @floatToInt(u16, //
+ std.math.ceil(@intToFloat(f32, possible.min + possible.max) / 2.0)),
+ else => return aoc.Error.InvalidInput,
+ };
+ }
+ if (possible.min != possible.max)
+ return aoc.Error.InvalidInput;
+ return possible.min;
+}
+
+fn part1(allocator: *std.mem.Allocator, input: []u8, args: [][]u8) !void {
+ var lineit = std.mem.tokenize(input, "\n");
+ var answer: ?u32 = null;
+ while (lineit.next()) |line| {
+ const row = try binarySearch(line[0..7], row_count, 'F', 'B');
+ const col = try binarySearch(line[7..10], col_count, 'L', 'R');
+ const id = row * 8 + col;
+ if (answer == null or id > answer.?)
+ answer = id;
+ }
+ std.debug.print("{}\n", .{answer.?});
+}
+
+fn part2(allocator: *std.mem.Allocator, input: []u8, args: [][]u8) !void {
+ var lineit = std.mem.tokenize(input, "\n");
+ var seats = [_]u1{0} ** (row_count * col_count);
+ while (lineit.next()) |line| {
+ const row = try binarySearch(line[0..7], row_count, 'F', 'B');
+ const col = try binarySearch(line[7..10], col_count, 'L', 'R');
+ const id = row * 8 + col;
+ seats[id] = 1;
+ }
+
+ for (seats) |b, i| {
+ if ((i == 0 or seats[i - 1] == 1) and
+ (i == seats.len - 1 or seats[i + 1] == 1) and seats[i] == 0)
+ {
+ std.debug.print("{}\n", .{i});
+ break;
+ }
+ }
+}
+
+pub const main = aoc.gen_main(part1, part2);
diff --git a/src/day5/part1 b/src/day5/part1
@@ -0,0 +1,53 @@
+--- Day 5: Binary Boarding ---
+
+You board your plane only to discover a new problem: you dropped your boarding pass! You aren't sure
+which seat is yours, and all of the flight attendants are busy with the flood of people that
+suddenly made it through passport control.
+
+You write a quick program to use your phone's camera to scan all of the nearby boarding passes (your
+puzzle input); perhaps you can find your seat through process of elimination.
+
+Instead of zones or groups, this airline uses [1m[37mbinary space partitioning[0m to seat people.
+A seat might be specified like FBFBBFFRLR, where F means "front", B means "back", L means "left",
+and R means "right".
+
+The first 7 characters will either be F or B; these specify exactly one of the [1m[37m128 rows[0m
+on the plane (numbered 0 through 127). Each letter tells you which half of a region the given seat
+is in. Start with the whole list of rows; the first letter indicates whether the seat is in the
+[1m[37mfront[0m (0 through 63) or the [1m[37mback[0m (64 through 127). The next letter
+indicates which half of that region the seat is in, and so on until you're left with exactly one
+row.
+
+For example, consider just the first seven characters of FBFBBFFRLR:
+
+- Start by considering the whole range, rows 0 through 127. - F means to take the [1m[37mlower
+half[0m, keeping rows 0 through 63. - B means to take the [1m[37mupper half[0m, keeping rows 32
+through 63. - F means to take the [1m[37mlower half[0m, keeping rows 32 through 47. - B means to
+take the [1m[37mupper half[0m, keeping rows 40 through 47. - B keeps rows 44 through 47. - F
+keeps rows 44 through 45. - The final F keeps the lower of the two, [1m[37mrow 44[0m.
+
+The last three characters will be either L or R; these specify exactly one of the [1m[37m8
+columns[0m of seats on the plane (numbered 0 through 7). The same process as above proceeds again,
+this time with only three steps. L means to keep the [1m[37mlower half[0m, while R means to keep
+the [1m[37mupper half[0m.
+
+For example, consider just the last 3 characters of FBFBBFFRLR:
+
+- Start by considering the whole range, columns 0 through 7. - R means to take the [1m[37mupper
+half[0m, keeping columns 4 through 7. - L means to take the [1m[37mlower half[0m, keeping
+columns 4 through 5. - The final R keeps the upper of the two, [1m[37mcolumn 5[0m.
+
+So, decoding FBFBBFFRLR reveals that it is the seat at [1m[37mrow 44, column 5[0m.
+
+Every seat also has a unique [1m[37mseat ID[0m: multiply the row by 8, then add the column. In
+this example, the seat has ID 44 * 8 + 5 = [1m[37m357[0m.
+
+Here are some other boarding passes:
+
+- BFFFBBFRRR: row 70, column 7, seat ID 567. - FFFBBBFRRR: row 14, column 7, seat ID 119. -
+BBFFBBFRLL: row 102, column 4, seat ID 820.
+
+As a sanity check, look through your list of boarding passes. [1m[37mWhat is the highest seat ID
+on a boarding pass?[0m
+
+
diff --git a/src/day5/part2 b/src/day5/part2
@@ -0,0 +1,14 @@
+--- Part Two ---
+
+[1m[37mDing![0m The "fasten seat belt" signs have turned on. Time to find your seat.
+
+It's a completely full flight, so your seat should be the only missing boarding pass in your list.
+However, there's a catch: some of the seats at the very front and back of the plane don't exist on
+this aircraft, so they'll be missing from your list as well.
+
+Your seat wasn't at the very front or back, though; the seats with IDs +1 and -1 from yours will be
+in your list.
+
+[1m[37mWhat is the ID of your seat?[0m
+
+