Exemplo n.º 1
0
        public void Test2(int steps, string expectedList)
        {
            var list = new SpinLocker(3);

            list.BuildList(steps);
            Assert.That(string.Join("", list.result.Select(_ => $"{(_==steps?"(":" ")}{_}{(_ == steps ? ")" : " ")}")).Trim(), Is.EqualTo(expectedList));
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            const int stepSize = 376;
            var       list     = new SpinLocker(stepSize);

            list.BuildList(2017);
            var index = list.result.IndexOf(2017);

            Console.WriteLine(list.result[index + 1].ToString());
            Console.WriteLine(list.result[1].ToString());

            int positionOfZero = 0;
            int valueAfterZero = 1;
            int lastIndex      = 1;

            for (int i = 1; i < 50_000_000; i++)
            {
                lastIndex = (lastIndex + stepSize) % i + 1;
                if (lastIndex == positionOfZero + 1)
                {
                    valueAfterZero = i;
                    Console.WriteLine(i);
                }
            }

            Console.WriteLine(valueAfterZero);

            Console.Read();
        }
Exemplo n.º 3
0
        public void Test1(int stepSize)
        {
            var list = new SpinLocker(stepSize);

            list.BuildList(2017);
            var index = list.result.IndexOf(2017);

            if (stepSize == 3)
            {
                Assert.That(list.result[index + 1], Is.EqualTo(638));
            }
            else
            {
                Assert.Pass(list.result[index + 1].ToString());
            }
        }