Embedded file directly into the binary

This commit is contained in:
2024-12-08 19:00:05 +01:00
parent d2f66dc8e9
commit 2aa4647c25
16 changed files with 33 additions and 160 deletions
+2 -7
View File
@@ -1,7 +1,7 @@
const std = @import("std");
const print = std.debug.print;
const file = @embedFile("input");
var file_buf: [140 * 141]u8 = undefined;
var matrice: [143][143]u8 = undefined;
const masks = [_][4][4]u8{
[4][4]u8{
@@ -81,12 +81,7 @@ fn setMatrice(c: u8) void {
}
fn fillMatrice() !void {
const file = try std.fs.cwd().openFile("day4/input", .{});
defer file.close();
_ = try file.readAll(&file_buf);
var iter = std.mem.split(u8, &file_buf, "\n");
var iter = std.mem.split(u8, file, "\n");
var x: usize = 1;
while (iter.next()) |line| {
+2 -7
View File
@@ -1,7 +1,7 @@
const std = @import("std");
const print = std.debug.print;
const file = @embedFile("input");
var file_buf: [140 * 141]u8 = undefined;
var matrice: [142][142]u8 = undefined;
const masks = [_][3][3]u8{
[3][3]u8{
@@ -53,12 +53,7 @@ fn setMatrice(c: u8) void {
}
fn fillMatrice() !void {
const file = try std.fs.cwd().openFile("day4/input", .{});
defer file.close();
_ = try file.readAll(&file_buf);
var iter = std.mem.split(u8, &file_buf, "\n");
var iter = std.mem.split(u8, file, "\n");
var x: usize = 1;
while (iter.next()) |line| {