r/dailyprogrammer • u/rya11111 3 1 • Feb 19 '12
[2/19/2012] Challenge #11 [easy]
The program should take three arguments. The first will be a day, the second will be month, and the third will be year. Then, your program should compute the day of the week that date will fall on.
13
Upvotes
2
u/[deleted] Feb 20 '12
Seems familiar...
4
u/blisse Feb 19 '12 edited Feb 19 '12
C++ Gaussian Algorithm from Wikipedia: http://en.wikipedia.org/wiki/Determination_of_the_day_of_the_week EDIT: oops forgot some bits (I did the other method with look up tables as well) Also, I don't know the built in methods to convert 0-6 to S-S and those :\
3
u/Crystal_Cuckoo Feb 20 '12
Python:
2
u/lukz 2 0 Feb 19 '12
Common Lisp
2
u/jnaranjo Feb 20 '12
I love python's "batteries included" philosophy.
http://pastebin.com/C6zSSiMZ
0
u/xueye Feb 20 '12
Okay, now you guys aren't even being discrete.
1
u/PrivatePilot Feb 19 '12
ruby
1
u/[deleted] Feb 19 '12 edited Feb 19 '12
Perl. Some reason couldn't get Date::Calc module to work so had to go for Date::Simple which necessitated the array.
1
u/HobbesianByChoice Feb 19 '12
JavaScript
To make it a little more challenging, I made it able to take the date and month in different formats.
getWeekday('19th', 'February', 2012);
getWeekday(19, 'Feb', 2012);
getWeekday(19, 02, 2012);
1
u/robin-gvx 0 2 Feb 20 '12
Déjà Vu implementation of the Gaussian algorithm: http://hastebin.com/raw/cududoniyu
1
u/Should_I_say_this Jun 23 '12
I wrote mine myself. Kinda proud but it's reinventing the wheel considering how short that other python solution was.
1
u/ragtag_creature Dec 12 '22
R
0
u/UnreasonableSteve Feb 19 '12
Gotta say this is unlikely to be easy without built-in date functions... but with them in PHP (too lazy to open a stream from STDIN sue me):
Also, it's limited to the unix epoch (1970 - 2038 or so)