static void Main(string[] args)
        {
            CandidateGenerator dumb = new DumbCandidateGenerator();
            CandidateGenerator smart = new SmartCandidateGenerator();

            foreach(var c in smart.GetPartitionedCandidates(8))
            {
                foreach(var e in c)
                    Console.WriteLine(e);
            }

        }
        static void Main(string[] args)
        {
            bool timedExecution = false;
            bool bruteForce = false;
            int procCount = Environment.ProcessorCount;
            Stopwatch sw = new Stopwatch();
            CandidateGenerator gen;
            #region Action<object> action = (object obj) =>
            Action<object> action = (object obj) => // Takes an enumerable of longs to iterate over.
            {
                IEnumerable<long> cans = (IEnumerable<long>)obj;

                Console.WriteLine($"New thread started with first element {cans.FirstOrDefault()}");
                foreach (var e in cans)
                {
                    //Console.WriteLine($"Testing : {e}");
                    if (isSelfReferential(e))
                    {
                        lock (AnswerMutex)
                        {
                            Answers.Add(e);
                        }
                    }
                }
            };
            #endregion

            if (args.Length >= 1) // We have initial arguments
            {
                timedExecution = (from v in args where v.ToUpperInvariant().Equals("-TIME") || v.ToUpperInvariant().Equals("-TIMER") || v.ToUpperInvariant().Equals("-TIMED") select v).Any();
                if ((from v in args where v.ToUpperInvariant().Equals("-BRUTE") || v.ToUpperInvariant().Equals("-BRUTEFORCE") || v.ToUpperInvariant().Equals("-BF") select v).Any())
                {
                    bruteForce = true;
                }
                else
                {
                    bruteForce = false;
                }
            }

            if (timedExecution)
            {
                Console.WriteLine(Properties.Resources.TimerStarted);
                sw.Start();
            }

            if (bruteForce)
            {
                Console.WriteLine(Properties.Resources.SearchBruteForce);
                gen = new DumbCandidateGenerator();
            }
            else // Doing it the smarter way
            {
                Console.WriteLine(Properties.Resources.SearchSmart);
                gen = new SmartCandidateGenerator();
            }

            Task[] tasks = new Task[procCount];
            int i = 0;
            foreach(var e in gen.GetPartitionedCandidates(procCount))
            {
                tasks[i++] = Task.Factory.StartNew(action, e);
            }

            Task.WaitAll(tasks);

            if (timedExecution)
            {
                sw.Stop();
                Console.WriteLine(Properties.Resources.ExecutionTime, sw.Elapsed, procCount);
            }
            Console.WriteLine(Environment.NewLine + Properties.Resources.Answers + Environment.NewLine + Properties.Resources.Dashes);
            foreach (var ans in Answers)
            {
                Console.WriteLine(ans);
            }
            Console.ReadKey();
        }