Created
August 14, 2020 21:01
-
-
Save khalidabuhakmeh/bfd94d48e034248cf6489b0349c9646c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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