private IEnumerable <string> LastMoments() { var lastMoments = new HashSet <string>(); while (true) { var program = RandomProgram.Generate(); var output = ExecuteSpringdroidProgram(program); if (!output.Any(c => c > 255)) { var lines = new string(output.Select(v => (char)v).ToArray()).Split('\n'); var lastMoment = lines.First(line => "#@".All(line.Contains)); if (!lastMoments.Contains(lastMoment)) { lastMoments.Add(lastMoment); yield return(lastMoment); } } } }
private (long, int, string) FindHullDamageResultByBruteForce(int length) { var memo = new HashSet <uint>(); var step = 0; while (true) { var program = RandomProgram.Generate(length); var signature = Hashing.Hash(program); if (memo.Contains(signature)) { continue; } memo.Add(signature); var damage = FindHullDamage(program); if (damage > 0) { return(damage, step, program); } step++; } }