public static int GetDaysBetween(DateTime start, DateTime end)
 {
     return(NumericSources.YieldSequenceFromTo(start.Year, end.Year).ToList().SelectWithBorderCases(
                x => GetDaysInFullYear(x),
                x => start.DayOfYear,
                x => end.DayOfYear).Sum());
 }
Exemple #2
0
        public void CalculateSmallestMultiple()
        {
            var    autod  = new AutoDictionary <double>();
            double result = 1;

            // for the sequence from 1-to-Input, get prime factors for each and store new ones (or higher powers)
            // Then get all factors and multiply them

            // Back then I didn't know IEnumerable.Range o.o
            NumericSources.YieldSequenceFromTo(1, Input).ForEach(x => autod.RegisterIfNew(x.GetPrimeFactors()));
            autod.Dictionary.ForEach(x => result *= Math.Pow(x.Key, x.Value));

            this.SmallestMultiple = result;
        }
Exemple #3
0
 public void Calculate()
 {
     this.SumOfSquares1 = NumericSources.YieldSequenceFromTo(1, InputCount).Select(x => x * x).Sum();
     this.SquareOfSums2 = Math.Pow(NumericSources.YieldSequenceFromTo(1, InputCount).Sum(), 2);
     DifferenceResult   = SquareOfSums2 - SumOfSquares1;
 }