Created
March 4, 2015 13:19
-
-
Save Sebbyastian/e946b70dd952d9824837 to your computer and use it in GitHub Desktop.
Challenge described at https://www.thenewboston.com/forum/topic.php?id=5311
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* (c) 2015 Sebastian Ramadan * | |
* May you perish in court if this makes its way into turnitin software, * | |
* ... for it is my intellectual property ;) * | |
*/ | |
#include <stdint.h> | |
#include <stdio.h> | |
int main(int argc, char **argv) { | |
uintmax_t y; | |
if (argc <= 1 || sscanf(argv[1], "%ju", &y) != 1) { | |
printf("Usage: %s year (where year is an integer between 0 and %ju)\n", argc && argv[0] ? argv[0] : "./app", UINTMAX_MAX); | |
return 0; | |
} | |
y--; | |
puts((char *[]) { "Sunday", "Monday" | |
, "Tuesday", "Wednesday" | |
, "Thursday", "Friday" | |
, "Saturday" }[(1 + 5 * (y % 4) + 4 * (y % 100) + 6 * (y % 400)) % 7]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment