Esempio n. 1
0
        public void MeasureMaskOptimization(string line)
        {
            var trainProblem = TrainResponse.Parse(line);

            byte[] p   = Parser.ParseFunction(trainProblem.challenge);
            var    ans = p.Printable();

            var operations = trainProblem.operators;
            var random     = new Random();
            var answers    = Enumerable.Range(0, 100).Select(i => random.NextUInt64()).Select(p.Eval).ToArray();
            var mask       = new Mask(answers);

            Console.WriteLine("          answers mask: {0}", mask);
            Console.WriteLine("challenge program mask: {0}", p.GetMask());
            Console.WriteLine("answer: {0}", ans);

            var sw = Stopwatch.StartNew();

            Assert.IsTrue(new BinaryBruteForcer(mask, 3, 1, operations).Enumerate(trainProblem.size - 1)
                          .Select(f => f.Printable())
                          .Any(found => found == ans));
            Console.WriteLine(sw.Elapsed);
            sw.Restart();
            Assert.IsTrue(
                new BinaryBruteForcer(operations).Enumerate(trainProblem.size - 1)
                .Any(found => found.Printable() == ans));
            Console.WriteLine(sw.Elapsed);
        }
Esempio n. 2
0
        public void MeasureMaskOptimization(string line)
        {
            var trainProblem = TrainResponse.Parse(line);

            Console.WriteLine(trainProblem.id);
            var prog       = trainProblem.challenge;
            var operations = trainProblem.operators;
            var maxSize    = trainProblem.size - 1;
            var minSize    = maxSize;

            TrySolve(prog, operations, minSize, maxSize, false);
//			CheckResult(ans, new SmartGenerator(inputs, answers, operations).Enumerate(trainProblem.size - 1));
        }