mirror of
https://codeberg.org/andyscott/advent-of-code.git
synced 2024-12-22 01:23:11 -05:00
Compare commits
No commits in common. "332eaae6ee55512027c349cfbce87f7028fa9045" and "1e3f01aef549887bbd959e0d10600d67a74d2d14" have entirely different histories.
332eaae6ee
...
1e3f01aef5
2 changed files with 11 additions and 8 deletions
|
@ -10,23 +10,23 @@ pub fn build(b: *std.Build) void {
|
|||
|
||||
var day: u8 = 1;
|
||||
while (day <= num_days) : (day += 1) {
|
||||
const name = b.fmt("day{d}", .{day});
|
||||
const file = b.fmt("{s}.zig", .{name});
|
||||
const str = b.fmt("day{d}", .{day});
|
||||
const file = b.fmt("{s}.zig", .{str});
|
||||
|
||||
const exe = b.addExecutable(.{
|
||||
.name = name,
|
||||
.name = str,
|
||||
.root_source_file = b.path(file),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
const install_exe = b.addInstallArtifact(exe, .{});
|
||||
const install_step = b.step(b.fmt("install_{s}", .{name}), b.fmt("Install {s}", .{name}));
|
||||
const install_step = b.step(b.fmt("install_{s}", .{str}), b.fmt("Install {s}", .{str}));
|
||||
install_step.dependOn(&install_exe.step);
|
||||
install_all.dependOn(&install_exe.step);
|
||||
|
||||
const run_exe = b.addRunArtifact(exe);
|
||||
const run_step = b.step(b.fmt("run_{s}", .{name}), b.fmt("Run {s}", .{name}));
|
||||
const run_step = b.step(b.fmt("run_{s}", .{str}), b.fmt("Run {s}", .{str}));
|
||||
run_step.dependOn(&run_exe.step);
|
||||
run_all.dependOn(&run_exe.step);
|
||||
}
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
const std = @import("std");
|
||||
const print = std.debug.print;
|
||||
|
||||
const util = @import("util.zig");
|
||||
|
||||
pub fn main() !void {
|
||||
const file = try std.fs.cwd().openFile("day1.txt", .{});
|
||||
defer file.close();
|
||||
|
||||
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
||||
defer std.debug.assert(gpa.deinit() == .ok);
|
||||
const allocator = gpa.allocator();
|
||||
|
||||
const input = try util.readAllInput(1, allocator);
|
||||
const stat = try file.stat();
|
||||
const input = try file.reader().readAllAlloc(allocator, stat.size);
|
||||
defer allocator.free(input);
|
||||
|
||||
var l1 = std.ArrayList(i32).init(allocator);
|
||||
|
|
Loading…
Reference in a new issue