// Hey puzzle designer, why ???? const std = @import("std"); pub fn main() !void { const stdin = std.io.getStdIn(); var buf_io = std.io.bufferedReader(stdin.reader()); var reader = buf_io.reader(); var buf = [_]u8{0} ** 100; _ = try reader.readAll(&buf); const stripped = std.mem.trim(u8, &buf, " \n\r\x00"); const solution = try mine(stripped); std.debug.print("{d}", .{solution}); } fn mine(key: []const u8) !u64 { var buf = [_]u8{0} ** 10000; for (1..1e10) |i| { const candidate = try std.fmt.bufPrintZ(&buf, "{s}{d}", .{ key, i }); var result = [_]u8{0} ** std.crypto.hash.Md5.digest_length; std.crypto.hash.Md5.hash(candidate, &result, .{}); // Check first 6 zeroes (3 bytes) if (result[0] == 0 and result[1] == 0 and result[2] == 0) { return i; } } return 0; }