Exemple #1
0
        static void Main(string[] args)
        {
            Spiral s = new Spiral();
            int    t = 312051;

            for (int i = 0; i < t; i++)
            {
                s.Add();
            }

            /* Part 1 */
            var sp = s[t];
            int d  = Math.Abs(sp.Coordinates.X) + Math.Abs(sp.Coordinates.Y);

            Console.WriteLine($"{sp} - D: {d}");

            /* Part 2 */
            foreach (SpiralValue sp2 in s)
            {
                Console.WriteLine($"{sp2} -> {sp2.SummedValue}");
                if (sp2.SummedValue > t)
                {
                    break;
                }
            }
        }