Example #1
0
        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);
                    }
                }
            }
        }
Example #2
0
        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++;
            }
        }