Compare commits
	
		
			No commits in common. "560db879293d2b544e04b26e03cdf2faac33cad2" and "579c643f3f9a0468bf664bf9503c43d42161b1fe" have entirely different histories.
		
	
	
		
			560db87929
			...
			579c643f3f
		
	
		
					 9 changed files with 1 additions and 162 deletions
				
			
		
							
								
								
									
										2
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
# ---> Zig
 | 
			
		||||
.zig-cache/
 | 
			
		||||
zig-cache/
 | 
			
		||||
zig-out/
 | 
			
		||||
build/
 | 
			
		||||
build-*/
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										75
									
								
								build.zig
									
										
									
									
									
								
							
							
						
						
									
										75
									
								
								build.zig
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,75 +0,0 @@
 | 
			
		|||
const std = @import("std");
 | 
			
		||||
 | 
			
		||||
pub fn build(b: *std.Build) !void {
 | 
			
		||||
    const allocator = b.allocator;
 | 
			
		||||
 | 
			
		||||
    const target = b.standardTargetOptions(.{});
 | 
			
		||||
    const optimize = b.standardOptimizeOption(.{});
 | 
			
		||||
 | 
			
		||||
    const run_all = b.step("run", "Run all days");
 | 
			
		||||
    const test_all = b.step("test", "Test all days");
 | 
			
		||||
    const check = b.step("check", "run checks");
 | 
			
		||||
 | 
			
		||||
    const utils_mod = b.createModule(.{ .root_source_file = b.path("src/utils/mod.zig") });
 | 
			
		||||
 | 
			
		||||
    var dirIt = (try std.fs.cwd().openDir(
 | 
			
		||||
        "./src/days",
 | 
			
		||||
        .{ .iterate = true },
 | 
			
		||||
    )).iterate();
 | 
			
		||||
 | 
			
		||||
    while (try dirIt.next()) |entry| {
 | 
			
		||||
        if (entry.kind == .directory) {}
 | 
			
		||||
        // each day entry will have a main.zig
 | 
			
		||||
        const source_file = try std.fs.path.join(allocator, &.{ "src", "days", entry.name, "main.zig" });
 | 
			
		||||
        defer allocator.free(source_file);
 | 
			
		||||
        //make sure the main.zig exists
 | 
			
		||||
        _ = std.fs.cwd().openFile(source_file, .{}) catch continue;
 | 
			
		||||
 | 
			
		||||
        const exe = b.addExecutable(.{
 | 
			
		||||
            .name = entry.name,
 | 
			
		||||
            .root_source_file = b.path(source_file),
 | 
			
		||||
            .target = target,
 | 
			
		||||
            .optimize = optimize,
 | 
			
		||||
        });
 | 
			
		||||
        exe.root_module.addImport("utils", utils_mod);
 | 
			
		||||
 | 
			
		||||
        b.installArtifact(exe);
 | 
			
		||||
        const install_cmd = b.addInstallArtifact(exe, .{});
 | 
			
		||||
        const install_step = b.step(
 | 
			
		||||
            b.fmt("install_{s}", .{entry.name}),
 | 
			
		||||
            b.fmt("install {s}", .{entry.name}),
 | 
			
		||||
        );
 | 
			
		||||
        install_step.dependOn(&install_cmd.step);
 | 
			
		||||
        b.installArtifact(exe);
 | 
			
		||||
 | 
			
		||||
        const run_cmd = b.addRunArtifact(exe);
 | 
			
		||||
        const run_step = b.step(
 | 
			
		||||
            b.fmt("run_{s}", .{entry.name}),
 | 
			
		||||
            b.fmt("run {s}", .{entry.name}),
 | 
			
		||||
        );
 | 
			
		||||
        run_step.dependOn(&run_cmd.step);
 | 
			
		||||
        run_all.dependOn(&run_cmd.step);
 | 
			
		||||
 | 
			
		||||
        const exe_test = b.addTest(.{
 | 
			
		||||
            .root_source_file = b.path(source_file),
 | 
			
		||||
            .target = target,
 | 
			
		||||
            .optimize = optimize,
 | 
			
		||||
        });
 | 
			
		||||
        const test_cmd = b.addRunArtifact(exe_test);
 | 
			
		||||
        const test_step = b.step(
 | 
			
		||||
            b.fmt("test_{s}", .{entry.name}),
 | 
			
		||||
            b.fmt("test {s}", .{entry.name}),
 | 
			
		||||
        );
 | 
			
		||||
        test_step.dependOn(&test_cmd.step);
 | 
			
		||||
        test_all.dependOn(&test_cmd.step);
 | 
			
		||||
 | 
			
		||||
        const exe_check = b.addExecutable(.{
 | 
			
		||||
            .name = entry.name,
 | 
			
		||||
            .root_source_file = b.path(source_file),
 | 
			
		||||
            .target = target,
 | 
			
		||||
            .optimize = optimize,
 | 
			
		||||
        });
 | 
			
		||||
        exe_check.root_module.addImport("utils", utils_mod);
 | 
			
		||||
        check.dependOn(&exe_check.step);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,46 +0,0 @@
 | 
			
		|||
.{
 | 
			
		||||
    // This is the default name used by packages depending on this one. For
 | 
			
		||||
    // example, when a user runs `zig fetch --save <url>`, this field is used
 | 
			
		||||
    // as the key in the `dependencies` table. Although the user can choose a
 | 
			
		||||
    // different name, most users will stick with this provided value.
 | 
			
		||||
    //
 | 
			
		||||
    // It is redundant to include "zig" in this name because it is already
 | 
			
		||||
    // within the Zig package namespace.
 | 
			
		||||
    .name = .aoc2024,
 | 
			
		||||
 | 
			
		||||
    // This is a [Semantic Version](https://semver.org/).
 | 
			
		||||
    // In a future version of Zig it will be used for package deduplication.
 | 
			
		||||
    .version = "0.0.1",
 | 
			
		||||
 | 
			
		||||
    // Together with name, this represents a globally unique package
 | 
			
		||||
    // identifier. This field is generated by the Zig toolchain when the
 | 
			
		||||
    // package is first created, and then *never changes*. This allows
 | 
			
		||||
    // unambiguous detection of one package being an updated version of
 | 
			
		||||
    // another.
 | 
			
		||||
    //
 | 
			
		||||
    // When forking a Zig project, this id should be regenerated (delete the
 | 
			
		||||
    // field and run `zig build`) if the upstream project is still maintained.
 | 
			
		||||
    // Otherwise, the fork is *hostile*, attempting to take control over the
 | 
			
		||||
    // original project's identity. Thus it is recommended to leave the comment
 | 
			
		||||
    // on the following line intact, so that it shows up in code reviews that
 | 
			
		||||
    // modify the field.
 | 
			
		||||
    .fingerprint = 0x25105d4386327470, // Changing this has security and trust implications.
 | 
			
		||||
 | 
			
		||||
    // Tracks the earliest Zig version that the package considers to be a
 | 
			
		||||
    // supported use case.
 | 
			
		||||
    .minimum_zig_version = "0.14.0",
 | 
			
		||||
 | 
			
		||||
    // Specifies the set of files and directories that are included in this package.
 | 
			
		||||
    // Only files and directories listed here are included in the `hash` that
 | 
			
		||||
    // is computed for this package. Only files listed here will remain on disk
 | 
			
		||||
    // when using the zig package manager. As a rule of thumb, one should list
 | 
			
		||||
    // files required for compilation plus any license(s).
 | 
			
		||||
    // Paths are relative to the build root. Use the empty string (`""`) to refer to
 | 
			
		||||
    // the build root itself.
 | 
			
		||||
    // A directory listed here means that all files within, recursively, are included.
 | 
			
		||||
    .paths = .{
 | 
			
		||||
        "build.zig",
 | 
			
		||||
        "build.zig.zon",
 | 
			
		||||
        "src",
 | 
			
		||||
    },
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1 +0,0 @@
 | 
			
		|||
const std = @import("std");
 | 
			
		||||
| 
						 | 
				
			
			@ -1,10 +0,0 @@
 | 
			
		|||
const std = @import("std");
 | 
			
		||||
const part1 = @import("part1.zig");
 | 
			
		||||
const part2 = @import("part2.zig");
 | 
			
		||||
const input = @embedFile("input.txt");
 | 
			
		||||
 | 
			
		||||
pub fn main() !void {
 | 
			
		||||
    const stdout = std.io.getStdErr().writer();
 | 
			
		||||
    try stdout.print("Part1: {d}\n", .{part1.solve(input)});
 | 
			
		||||
    try stdout.print("Part2: {d}\n", .{part2.solve(input)});
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,14 +0,0 @@
 | 
			
		|||
const lib = @import("lib.zig");
 | 
			
		||||
const std = @import("std");
 | 
			
		||||
const utils = @import("utils");
 | 
			
		||||
 | 
			
		||||
pub fn solve(comptime input: []const u8) i32 {
 | 
			
		||||
    return input.len;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test "part1 sample" {
 | 
			
		||||
    const input =
 | 
			
		||||
        \\0
 | 
			
		||||
    ;
 | 
			
		||||
    try std.testing.expectEqual(solve(input), 1);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,14 +0,0 @@
 | 
			
		|||
const lib = @import("lib.zig");
 | 
			
		||||
const std = @import("std");
 | 
			
		||||
const utils = @import("utils");
 | 
			
		||||
 | 
			
		||||
pub fn solve(comptime input: []const u8) i32 {
 | 
			
		||||
    return input.len;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
test "part2 sample" {
 | 
			
		||||
    const input =
 | 
			
		||||
        \\0
 | 
			
		||||
    ;
 | 
			
		||||
    try std.testing.expectEqual(solve(input), 1);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1 +0,0 @@
 | 
			
		|||
const std = @import("std");
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue