예제 #1
0
        private static CircularLinkedList InitializeList(int numberOfplayer)
        {
            _playerListNode = new CircularLinkedList();
            for (int i = 1; i <= numberOfplayer; i++)
            {
                _playerListNode.AddLast(0, i);
            }

            return(_playerListNode);
        }
예제 #2
0
        public static int PlayGame(int input1, int input2, int input3)
        {
            _playerListNode = InitializeList(input1);
            var isEven = false;
            var result = 0;

            if (input1 < 3 || input1 > 1000)
            {
                return(-1);
            }
            if (input2 < 3 || input2 > 1000)
            {
                return(-1);
            }
            _playerListNode.StartGame();
            while (_playerListNode.MaxValue != input2)
            {
                var head = isEven ? _playerListNode.MooveForwardAndSetValue(input3) : _playerListNode.MooveBackwardAndSetValue(input3);
                isEven = head.Value % 2 == 0;
                result++;
            }

            return(result);
        }