private void createHistogram(StringBuilder report, WeatherDataCollection tempWeatherCollection, int lowerBound, int upperBound, int bucketSize, HighLow highOrLow) { var initialTierLowerBound = lowerBound - (lowerBound % bucketSize); int initialOffset = 1; var initialTierUpperBound = initialTierLowerBound + bucketSize - initialOffset; var highestTierOffset = bucketSize - 1; var finalTierUpperBound = upperBound - upperBound % bucketSize + highestTierOffset; while (initialTierLowerBound <= finalTierUpperBound) { int countOfDays; if (highOrLow.Equals(HighLow.High)) { countOfDays = tempWeatherCollection.CountDaysWithHighBetween(initialTierLowerBound, initialTierUpperBound); } else { countOfDays = tempWeatherCollection.CountDaysWithLowBetween(initialTierLowerBound, initialTierUpperBound); } report.Append( $"{initialTierLowerBound}-{initialTierUpperBound}: {countOfDays} {Environment.NewLine}"); initialTierLowerBound = initialTierLowerBound + bucketSize; initialTierUpperBound = initialTierUpperBound + bucketSize; } }