public void SolveTest8()
        {
            int[]        arr     = new[] { 0, 1, 1, 0, 0, 0, 0, 1, 0, 1 };
            ArrayModifer modifer = new ArrayModifer();

            for (int i = 1; i <= 100; i++)
            {
                if (i % 10 == 0)
                {
                    arr = modifer.ArrayModify((ArrayAction)(i / 10), arr);
                }
                var      simuator = new FullQ4Simulator(arr, new CacheRandomMemoryChanger(), 1);
                ESAbATAd sol      = new ESAbATAd(simuator);
                var      res      = sol.Solve();
                var      expected = new string(simuator.MemoryArray.Select(x => (char)(x + '0')).ToArray());
                var      actual   = new string(sol.MemoryFinder.MemoryArr.Select(x => (char)(x + '0')).ToArray());
                try
                {
                    Assert.AreEqual("Y", res);
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
Esempio n. 2
0
        public void WriteLine(string message)
        {
            if (ErrorOccuer)
            {
                throw new InvalidOperationException("You have a mistke, system is closed");
            }


            if (query % 10 == 1)
            {
                MemoryArray = modifer.ArrayModify(memoryChanger.GetActionToPreform(), MemoryArray);
            }

            if (message.Length > 4)
            {
                var answer = memoryArrayStr == message ? 'Y' : 'N';
                outputBuffer.Enqueue(answer);
                if (answer == 'N')
                {
                    ErrorOccuer = true;
                }
            }
            else
            {
                if (query == 150)
                {
                    ErrorOccuer = true;
                    throw new InvalidOperationException("You have a reach the max guess of 150, system is closed");
                }
                query++;
                int idx = int.Parse(message);
                try
                {
                    var temp = MemoryArray[idx - 1];
                    outputBuffer.Enqueue((char)('0' + temp));
                }
                catch (IndexOutOfRangeException)
                {
                    outputBuffer.Enqueue('N');
                    ErrorOccuer = true;
                }
            }
        }