15
What is the shortest program that can predict the next time Friday will fall on the 13th day of the month?
- Must be an complete functioning program (not just a function/subroutine)
- Must print out date in the following format:
YYYY-MM-DD
- Allow user to provide a start date either as a command line argument or through
STDIN
- If user provides no start date, use today as the start date.
- If the start date is a Friday the 13th, the program should find the next Friday the 13th.
If I were to run the program today (Feb 16 2011) I should get the following output.
$ ./fr13th 2013-05-09
2013-09-13
$ ./fr13th 2007-06-29
2007-07-13
$ ./fr13th 2007-07-13
2008-06-13
$ ./fr13th
2011-05-13
Would a
2013-9-13
output be ok for the first example? – J B – 2011-02-16T16:05:11.590Do you mean we can decide whether we want to take the date as an argument or from STDIN or that we need to support both? – sepp2k – 2011-02-16T16:58:05.210
@sepp2k You can decide, you don't need to support both, the user just needs a way to input a date. – Daniel Standage – 2011-02-16T18:06:00.600
@JB Yeah, since there are several other solutions that do address all of the requirements, I wouldn't accept your response as the solution even if it was the shortest. That doesn't mean your response wasn't informative...but yeah, dealing with an inconsistent date format would be frustrating. – Daniel Standage – 2011-02-16T20:50:48.383
Well this one is not really possible with golfscript because it doesn't know today's date. It also doesn't have a date library so would likely be quite a large answer anyway. (you can use ruby eval to get it, but then might as well use ruby date lib too) – gnibbler – 2011-02-16T21:21:16.557
@Daniel Standage: my question predates those, so that makes for a weak argument; but the decision is acceptable on its own nonetheless. – J B – 2011-02-16T22:40:07.660