day 2 start
This commit is contained in:
1
25/2/input.txt
Normal file
1
25/2/input.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
655-1102,2949-4331,885300-1098691,1867-2844,20-43,4382100-4484893,781681037-781860439,647601-734894,2-16,180-238,195135887-195258082,47-64,4392-6414,6470-10044,345-600,5353503564-5353567532,124142-198665,1151882036-1151931750,6666551471-6666743820,207368-302426,5457772-5654349,72969293-73018196,71-109,46428150-46507525,15955-26536,65620-107801,1255-1813,427058-455196,333968-391876,482446-514820,45504-61820,36235767-36468253,23249929-23312800,5210718-5346163,648632326-648673051,116-173,752508-837824
|
||||||
@@ -1,27 +1,27 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const _2 = @import("_2");
|
|
||||||
|
|
||||||
pub fn main() !void {
|
pub fn main() !void {
|
||||||
// Prints to stderr, ignoring potential errors.
|
var res: i32 = 0;
|
||||||
std.debug.print("All your {s} are belong to us.\n", .{"codebase"});
|
res ^= res;
|
||||||
try _2.bufferedPrint();
|
//var res2: i32 = 0;
|
||||||
|
|
||||||
|
var file = try std.fs.cwd().openFile("input.txt", .{});
|
||||||
|
defer file.close();
|
||||||
|
|
||||||
|
var buf: [64]u8 = undefined;
|
||||||
|
var fr = file.reader(&buf);
|
||||||
|
|
||||||
|
var stdout_buf: [1024]u8 = undefined;
|
||||||
|
var stdout = std.fs.File.stdout().writer(&stdout_buf);
|
||||||
|
|
||||||
|
while (try fr.interface.takeDelimiter(',')) |line| {
|
||||||
|
|
||||||
|
var val: i32 = try std.fmt.parseInt(i32, line[1..], 10);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test "simple test" {
|
try stdout.interface.print("{}\n", .{ res });
|
||||||
const gpa = std.testing.allocator;
|
try stdout.interface.flush();
|
||||||
var list: std.ArrayList(i32) = .empty;
|
|
||||||
defer list.deinit(gpa); // Try commenting this out and see if zig detects the memory leak!
|
|
||||||
try list.append(gpa, 42);
|
|
||||||
try std.testing.expectEqual(@as(i32, 42), list.pop());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test "fuzz example" {
|
|
||||||
const Context = struct {
|
|
||||||
fn testOne(context: @This(), input: []const u8) anyerror!void {
|
|
||||||
_ = context;
|
|
||||||
// Try passing `--fuzz` to `zig build test` and see if it manages to fail this test case!
|
|
||||||
try std.testing.expect(!std.mem.eql(u8, "canyoufindme", input));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
try std.testing.fuzz(Context{}, Context.testOne, .{});
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user