Пример #1
0
        private bool _Start(int step)
        {
            if (step > (ProgramSize - 1))
            {
                return(false);
            }
            char ins;

            for (int i = 0; i < CommandsLength; i++)
            {
                ins = commands[i];
                if (OkCommand(ins, step))
                {
                    Program[step] = ins;
                    //bool test = false;
                    string program = new string(Program);
                    //var bf = new BrainFuck();//instance as general one
                    try
                    {
                        bf.Run(program);
                        if (bf.BFPrintHistory().IndexOf(target) > 0)
                        {
                            return(true);
                        }
                    }
                    catch
                    {
                    }
                    Console.WriteLine($"Generated {program}");
                    if (_Start(step + 1))
                    {
                        return(true);
                    }
                }
            }
            Program[step] = '\0';
            return(false);
        }