Switch to i64 for words
This commit is contained in:
@@ -3,7 +3,7 @@ const std = @import("std");
|
||||
const intcode = @import("intcode");
|
||||
|
||||
// TODO: it would be awesome if we could make this a comptime function
|
||||
const perm1 = [120][5]i32{
|
||||
const perm1 = [120][5]intcode.Word{
|
||||
.{ 0, 1, 2, 3, 4 },
|
||||
.{ 0, 1, 2, 4, 3 },
|
||||
.{ 0, 1, 3, 2, 4 },
|
||||
@@ -126,7 +126,7 @@ const perm1 = [120][5]i32{
|
||||
.{ 4, 3, 2, 1, 0 },
|
||||
};
|
||||
|
||||
const perm2 = [120][5]i32{
|
||||
const perm2 = [120][5]intcode.Word{
|
||||
.{ 5, 6, 7, 8, 9 },
|
||||
.{ 5, 6, 7, 9, 8 },
|
||||
.{ 5, 6, 8, 7, 9 },
|
||||
@@ -255,13 +255,13 @@ fn doIt(m: *intcode.Machine) void {
|
||||
}
|
||||
}
|
||||
|
||||
fn run(program: []i32, machines: *[5]intcode.Machine, permutations: [120][5]i32) !i32 {
|
||||
var max: i32 = 0;
|
||||
fn run(program: []intcode.Word, machines: *[5]intcode.Machine, permutations: [120][5]intcode.Word) !intcode.Word {
|
||||
var max: intcode.Word = 0;
|
||||
|
||||
for (permutations) |inputs| {
|
||||
// Reset program state each time
|
||||
for (machines) |*machine, i| {
|
||||
std.mem.copy(i32, machine.memory, program);
|
||||
std.mem.copy(intcode.Word, machine.memory, program);
|
||||
machine.ip = 0;
|
||||
machine.idx = i;
|
||||
}
|
||||
@@ -308,7 +308,7 @@ pub fn main() anyerror!void {
|
||||
// Allocate memory once only.
|
||||
for (machines) |*machine| {
|
||||
machine.alloc = alloc;
|
||||
machine.memory = try alloc.alloc(i32, program.len);
|
||||
machine.memory = try alloc.alloc(intcode.Word, program.len);
|
||||
}
|
||||
|
||||
// Now wire up the machines correctly. The output of each machine should be
|
||||
|
Reference in New Issue
Block a user