Ejemplo n.º 1
0
        private static void TryAllCombinations(LongCodeComputer c, string[] items)
        {
            for (int itemCount = 1; itemCount <= items.Length; itemCount++)
            {
                foreach (var dropping in new Combinations <string>(items, itemCount))
                {
                    foreach (var item in dropping)
                    {
                        TypeIn(c, "drop " + item);
                    }

                    TypeIn(c, "inv");
                    _ = c.RunUntilInputRequired();
                    PrintOutputs(c);

                    TypeIn(c, "west");

                    if (!c.RunUntilInputRequired())
                    {
                        return;
                    }

                    PrintOutputs(c);

                    foreach (var item in dropping)
                    {
                        TypeIn(c, "take " + item);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        static void Main()
        {
            var input = File.ReadAllText(@"../../../input.txt").ParseLongs();

            var sw = new Stopwatch();

            sw.Start();

            var c = new LongCodeComputer(input);

            c.Store(0, 2);
            _ = c.RunUntilInputRequired();

            AddTiles(c.Outputs);

            var blockCount = tiles.Count(x => x.Value == 2);

            Console.WriteLine($"Part 1: {blockCount}");
            _ = Console.ReadLine();

            var width  = 42;
            var height = 22;

            Console.BufferWidth  = Math.Max(width, Console.BufferWidth);
            Console.BufferHeight = Math.Max(height + 10, Console.BufferHeight);

            var frameCounter = 0;

            do
            {
                AddTiles(c.Outputs);
                if (frameCounter++ % 1 == 0)
                {
                    PaintGame();
                }

                var relPos = Math.Sign(ballPosition.CompareTo(paddlePosition));
                c.Inputs.Enqueue(relPos);
            } while (c.RunUntilInputRequired());

            // Last Paint
            AddTiles(c.Outputs);
            PaintGame();

            _ = Console.ReadLine();
        }