5
Since I want to celebrate this definitely not nerdy event, your job is to calculate the piversary (pi-anniversary) of a given date.
Input
Your code has to have a possibilty to input a date in the format DD/MM/YYYY
. You can expect, that the input is valid and the year is 0000<YYYY<9996
.
Output
You have to release two dates, the date in Pi months and the date in Pi years.
Rules
- If your language hasn't a build in Pi, you have to make a variable which will be exact enough to calculate the dates, but it is not allowed to calculate the days separately and use fix numbers.
- You have to take care, that the months have different amount of days, but you don't have to care about leap years (only if you want).
- If you calculate the date, you have to add the three years/months first and then the left part in rounded days.
- Your code has to accept any valid date and should be able to handle edge cases like
30/12/2000
Example:
Input: 12/04/2010
Calculate monthly piversary:
date + 3 months = 12/07/2010
date + (31*(Pi-3)) = date + 4.39 = date + 4 = 16/07/2010 //31 because July has 31 days
Calculate yearly piversary:
date + 3 years = 12/04/2013
date + (365*(Pi-3)) = date + 52 = 03/06/2013
Output:
16/07/2010,03/06/2013
May the shortest code win.
7xkcd.com/1179 – Zaq – 2014-07-31T15:09:56.130
Are leading zeroes required in the output? – NinjaBearMonkey – 2014-07-31T15:16:51.930
@Zaq Awesome picture :) I will use it next time, I promise. – izlin – 2014-08-01T05:44:20.487
@hsl Yes they are. – izlin – 2014-08-01T05:44:41.303