When is Thanksgiving?
TI-BASIC, 15 bytes * 0.75 = 11.25
Tested on my TI-84+ calculator
1129-dayOfWk(Ans+ᴇ4,9,1
Thankgiving is November 29, minus the day of the week of September 1st, where 1 is Sunday and 7 is Saturday. This outputs in the format MMDD
.
Test cases: 2015
-> 1126
, 1917
-> 1122
, -480
-> 1125
have been verified. TI-BASIC seems to use the Gregorian calendar for all dates.
TI-BASIC doesn't support negative years, but this gets the bonus because we add 10000 to the input. Because the Gregorian calendar has a period of 400 years, this doesn't change the day of the week.
PHP, 65 48 42 41 36 (+2 for -F
) = 38 bytes
<?date(Md,strtotime("4thuXI$argn"));
Takes input as the first command line argument. Runs with warnings, which are acceptable by our rules. Prints NovDD
, where DD
is the day of Thanksgiving.
No online link because ideone doesn't support command line args and I don't know of an online interpreter that does.
Thanks to Alexander O'Mara for teaching me a new trick, and primo for a significant reduction
Mathematica, 59 38 bytes
DayRange[{#,11},{#,12},Thursday][[4]]&