Skip to content

Instantly share code, notes, and snippets.

@Sebbyastian
Created March 4, 2015 13:19
Show Gist options
  • Save Sebbyastian/e946b70dd952d9824837 to your computer and use it in GitHub Desktop.
Save Sebbyastian/e946b70dd952d9824837 to your computer and use it in GitHub Desktop.
/* (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