using System.Text.RegularExpressions;
public static void Main()
Console.WriteLine("Hello Unique :)");
Console.WriteLine("---------------");
Console.WriteLine("TASK 1");
Console.WriteLine("---------------");
DateTime today = DateTime.Now;
for (int i = 0; i < 12; i++)
index = DateHelper.GetDateForLastDayOfWeek(DayOfWeek.Monday, today.AddDays(-i * 7));
Console.WriteLine(i + 1 + ") " + index.ToString(DateHelper.AU_DATETIME_FORMAT));
Console.WriteLine("Please Enter two-digit number to find its position in pi:");
Console.WriteLine("(e.g. 15 has position 3 in 3.14159.....)");
string pattern = Console.ReadLine();
if (pattern.Length == 2 && Regex.IsMatch(pattern, @"^\d+$"))
int position = Lib.PositionSearchInPie(pattern);
Console.WriteLine(pattern + " was not found");
Console.WriteLine(pattern + " found at digit " + position.ToString());
Console.WriteLine("Error: You entered '{0}' is not a two-digit number. Please try again.", pattern);
public static class DateHelper
public static string AU_DATETIME_FORMAT = "dd MMMM, yyyy";
public static DateTime GetDateForLastDayOfWeek(DayOfWeek DOW, DateTime DATE)
int adjustment = ((int)DATE.DayOfWeek < (int)DOW ? 7 : 0);
return DATE.AddDays(0 - (((int)(DATE.DayOfWeek) + adjustment) - (int)DOW));
public static Regex REG_EXP = new Regex("[^0-9]");
public static int PositionSearchInPie(string pattern)
pattern = REG_EXP.Replace(pattern, "");
string Pi = Math.PI.ToString().Replace(".", "");
return Pi.IndexOf(pattern);