Last active
December 7, 2019 15:43
-
-
Save markhc/abe13d6a6e84b134bb17705fa6811326 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var phaseSetting = new int[] { 0, 1, 2, 3, 4 }; | |
var maxThrusters = UInt64.MinValue; | |
do { | |
var vms = phaseSetting | |
.Select(x => new Intcode((int[])memory.Clone(), x.ToString())) | |
.ToArray(); | |
var signal = "0"; | |
while (!vms.Last().HasFinished) { | |
foreach (var vm in vms) { | |
signal = vm.Run(signal); | |
} | |
} | |
maxThrusters = Math.Max(UInt64.Parse(signal), maxThrusters); | |
} while (Permutations.NextPermutation(phaseSetting)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment