Switch to using a queue for character devices
This commit is contained in:
@@ -28,7 +28,7 @@ pub fn main() anyerror!void {
|
||||
var program = try intcode.loadFromStdIn(alloc);
|
||||
|
||||
// Part 1
|
||||
std.debug.warn("Part 1: {}\n", try runCopy(alloc, program, 12, 2));
|
||||
std.debug.warn("Day 2, Part 1: {}\n", try runCopy(alloc, program, 12, 2));
|
||||
|
||||
// Part 2: 100*100 = 10,000 combinations to try.
|
||||
var memory: []i32 = try alloc.alloc(i32, program.len);
|
||||
@@ -36,14 +36,14 @@ pub fn main() anyerror!void {
|
||||
var noun: i32 = 0;
|
||||
var verb: i32 = 0;
|
||||
|
||||
std.debug.warn("Part 2: Searching...");
|
||||
std.debug.warn("Day 2, Part 2: ");
|
||||
while (!done) {
|
||||
std.mem.copy(i32, memory, program);
|
||||
const result = try run(alloc, memory, noun, verb);
|
||||
|
||||
// Too high: 250800 (noun=33, verb=76)
|
||||
if (result == 19690720) {
|
||||
std.debug.warn("OK! noun={} verb={}\n", noun, verb);
|
||||
std.debug.warn("noun={} verb={}\n", noun, verb);
|
||||
done = true;
|
||||
}
|
||||
|
||||
@@ -54,8 +54,6 @@ pub fn main() anyerror!void {
|
||||
|
||||
if (verb > 100) {
|
||||
std.debug.warn("failed!\n");
|
||||
} else {
|
||||
std.debug.warn(".");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user