Esempio n. 1
0
 static void Main(string[] args)
 {
     while (true)
     {
         Console.WriteLine("Brainfuck コードを書いてください");
         Console.Write("> ");
         var code  = Console.ReadLine();
         var token = BrainFuck.Tokenize(code);
         BrainFuck.Run(token);
     }
 }
Esempio n. 2
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);
        }