Skip to content

Instantly share code, notes, and snippets.

@khalidabuhakmeh
Created August 14, 2020 21:01
Show Gist options
  • Save khalidabuhakmeh/bfd94d48e034248cf6489b0349c9646c to your computer and use it in GitHub Desktop.
Save khalidabuhakmeh/bfd94d48e034248cf6489b0349c9646c to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
public static class Program
{
public const int TotalTips = 61;
private static void Main()
{
const int year = 2020;
var dates = new List<DateTime>();
for (int month = 1; month <= 12; month++)
for (int day = 1; day <= DateTime.DaysInMonth(year, month); day++)
dates.Add(new DateTime(year, month, day));
Console.Clear();
foreach (var date in dates)
{
var result = GetTip(date);
Console.WriteLine($"{date.DayOfYear}: {result}");
}
}
private static int GetTip(DateTime date)
{
// assume reading these from disk
var tips = Enumerable
.Range(1, TotalTips)
.ToList();
var result = tips[((date.DayOfYear - 1) % TotalTips)];
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment