Пример #1
0
        private IEnumerable <int> Play(string inData, int numberSpoken, bool part2 = false)
        {
            int[] input = { 20, 0, 1, 11, 6, 3 };
            int   ctr   = 0;

            shout[] arr = new shout[numberSpoken];

            for (int y = 0; y < input.Count() - 1; y++)
            {
                arr[input[y]].lastTurn = ctr++;
                arr[input[y]].exists   = true;
            }

            int nextNumber = input[input.Count() - 1];
            int lastNumber = -1;

            while (ctr < numberSpoken)
            {
                lastNumber = nextNumber;

                if (arr[nextNumber].exists == false)
                {
                    arr[nextNumber].lastTurn = ctr;
                    arr[nextNumber].exists   = true;
                    nextNumber = 0;
                }
                else
                {
                    int tmp = ctr - arr[nextNumber].lastTurn;
                    arr[nextNumber].lastTurn = ctr;
                    nextNumber = tmp;
                }
                ctr++;

                //if (ctr % 1000000 == 0 || ctr == 10 || ctr == numberSpoken) DrawTextProgressBar(ctr+2, numberSpoken, true);
            }

            //System.Threading.Thread.Sleep(500);
            //stopwatch.Stop();
            //Console.WriteLine("(" + stopwatch.ElapsedMilliseconds + "ms)\n");

            //return lastNumber;
            //List<string> input = inData.Split("\r\n").ToList();
            yield return(lastNumber);
        }
Пример #2
0
 Usage The MessageRouter is flexible and can handle many different scenarios. As an example, imagine an air combat game in which pilots communicate through our MessageRouter. A pilot might broadcast (shout) an "Under attack!" message if they feel threatened.