Skip to content

Instantly share code, notes, and snippets.

@torokati44
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save torokati44/4d73567c6d2d1b2ea8a7 to your computer and use it in GitHub Desktop.
Save torokati44/4d73567c6d2d1b2ea8a7 to your computer and use it in GitHub Desktop.
#include <stdio.h>
char *names[] = { "spock", "scissors", "paper", "rock", "lizard" };
int result(int a, int b) {
return a == b ? 0 : ( 5 - a + b ) % 5 % 2 * 2 - 1;
}
int main() {
for (int i = 0; i < 5; ++i)
for (int j = 0; j < 5; ++j)
printf("%s %c %s\n", names[i], '=' + result(i, j), names[j]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment