public long Part1() { Task <long> GetOutput(IEnumerable <int> phases) { var pipe = new AmplifiersPipe(_code, phases.ToArray(), _input); return(pipe.ExecuteAsync()); } return(new Permutations <int>(Enumerable.Range(0, 5).ToArray()).Select(x => GetOutput(x).Result).Max()); }
public long Part2() { async Task <long> GetOutput(IEnumerable <int> phases) { var pipe = new AmplifiersPipe(_code, phases.ToArray(), _input); return(await pipe.ExecuteAsync()); } var permutations = new Permutations <int>(Enumerable.Range(5, 5).ToArray()); var result = permutations.Select(x => GetOutput(x).Result).ToArray(); return(result.Any() ? result.Max() : -1); }