Created
October 30, 2013 12:55
-
-
Save chunkyguy/7232209 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#include <stdio.h> | |
#include <string.h> | |
char *map = | |
"xxxxxx000xxxxxx" | |
"xxxxxx0r0xxxxxx" | |
"xxxxxx0r0xxxxxx" | |
"xxxxxx0r0xxxxxx" | |
"xxxxxx0r0xxxxxx" | |
"xxxxxx0r0xxxxxx" | |
"000000hhh000000" | |
"0ggggghhhbbbbb0" | |
"000000hhh000000" | |
"xxxxxx0y0xxxxxx" | |
"xxxxxx0y0xxxxxx" | |
"xxxxxx0y0xxxxxx" | |
"xxxxxx0y0xxxxxx" | |
"xxxxxx0y0xxxxxx" | |
"xxxxxx000xxxxxx" | |
; | |
#define is_flag(i, f) ((map[i] == f) || (map[i] == '0')) | |
int main(int argc, char *argv[]) { | |
char flag = ' '; | |
if (argc > 1) { | |
flag = argv[1][0]; | |
} | |
printf("argc: %d flag: %c\n", argc, flag); | |
int k = 0; | |
for (int i = 0; i < 15; ++i) { | |
for (int j = 0; j < 15; ++j, ++k) { | |
if (strchr("rgby0",flag)) { | |
printf("%4d",is_flag(i*15+j, flag)?k:0); | |
} else { | |
printf("%4d",k); | |
} | |
} | |
printf("\n"); | |
} | |
return 0; | |
} | |
/* | |
OUTPUT | |
wl:learn sidharthjuyal$ clang print_ludo.c -o print_ludo && ./print_ludo r | |
argc: 2 flag: r | |
0 0 0 0 0 0 6 7 8 0 0 0 0 0 0 | |
0 0 0 0 0 0 21 22 23 0 0 0 0 0 0 | |
0 0 0 0 0 0 36 37 38 0 0 0 0 0 0 | |
0 0 0 0 0 0 51 52 53 0 0 0 0 0 0 | |
0 0 0 0 0 0 66 67 68 0 0 0 0 0 0 | |
0 0 0 0 0 0 81 82 83 0 0 0 0 0 0 | |
90 91 92 93 94 95 0 0 0 99 100 101 102 103 104 | |
105 0 0 0 0 0 0 0 0 0 0 0 0 0 119 | |
120 121 122 123 124 125 0 0 0 129 130 131 132 133 134 | |
0 0 0 0 0 0 141 0 143 0 0 0 0 0 0 | |
0 0 0 0 0 0 156 0 158 0 0 0 0 0 0 | |
0 0 0 0 0 0 171 0 173 0 0 0 0 0 0 | |
0 0 0 0 0 0 186 0 188 0 0 0 0 0 0 | |
0 0 0 0 0 0 201 0 203 0 0 0 0 0 0 | |
0 0 0 0 0 0 216 217 218 0 0 0 0 0 0 | |
wl:learn sidharthjuyal$ clang print_ludo.c -o print_ludo && ./print_ludo g | |
argc: 2 flag: g | |
0 0 0 0 0 0 6 7 8 0 0 0 0 0 0 | |
0 0 0 0 0 0 21 0 23 0 0 0 0 0 0 | |
0 0 0 0 0 0 36 0 38 0 0 0 0 0 0 | |
0 0 0 0 0 0 51 0 53 0 0 0 0 0 0 | |
0 0 0 0 0 0 66 0 68 0 0 0 0 0 0 | |
0 0 0 0 0 0 81 0 83 0 0 0 0 0 0 | |
90 91 92 93 94 95 0 0 0 99 100 101 102 103 104 | |
105 106 107 108 109 110 0 0 0 0 0 0 0 0 119 | |
120 121 122 123 124 125 0 0 0 129 130 131 132 133 134 | |
0 0 0 0 0 0 141 0 143 0 0 0 0 0 0 | |
0 0 0 0 0 0 156 0 158 0 0 0 0 0 0 | |
0 0 0 0 0 0 171 0 173 0 0 0 0 0 0 | |
0 0 0 0 0 0 186 0 188 0 0 0 0 0 0 | |
0 0 0 0 0 0 201 0 203 0 0 0 0 0 0 | |
0 0 0 0 0 0 216 217 218 0 0 0 0 0 0 | |
wl:learn sidharthjuyal$ clang print_ludo.c -o print_ludo && ./print_ludo y | |
argc: 2 flag: y | |
0 0 0 0 0 0 6 7 8 0 0 0 0 0 0 | |
0 0 0 0 0 0 21 0 23 0 0 0 0 0 0 | |
0 0 0 0 0 0 36 0 38 0 0 0 0 0 0 | |
0 0 0 0 0 0 51 0 53 0 0 0 0 0 0 | |
0 0 0 0 0 0 66 0 68 0 0 0 0 0 0 | |
0 0 0 0 0 0 81 0 83 0 0 0 0 0 0 | |
90 91 92 93 94 95 0 0 0 99 100 101 102 103 104 | |
105 0 0 0 0 0 0 0 0 0 0 0 0 0 119 | |
120 121 122 123 124 125 0 0 0 129 130 131 132 133 134 | |
0 0 0 0 0 0 141 142 143 0 0 0 0 0 0 | |
0 0 0 0 0 0 156 157 158 0 0 0 0 0 0 | |
0 0 0 0 0 0 171 172 173 0 0 0 0 0 0 | |
0 0 0 0 0 0 186 187 188 0 0 0 0 0 0 | |
0 0 0 0 0 0 201 202 203 0 0 0 0 0 0 | |
0 0 0 0 0 0 216 217 218 0 0 0 0 0 0 | |
wl:learn sidharthjuyal$ clang print_ludo.c -o print_ludo && ./print_ludo b | |
argc: 2 flag: b | |
0 0 0 0 0 0 6 7 8 0 0 0 0 0 0 | |
0 0 0 0 0 0 21 0 23 0 0 0 0 0 0 | |
0 0 0 0 0 0 36 0 38 0 0 0 0 0 0 | |
0 0 0 0 0 0 51 0 53 0 0 0 0 0 0 | |
0 0 0 0 0 0 66 0 68 0 0 0 0 0 0 | |
0 0 0 0 0 0 81 0 83 0 0 0 0 0 0 | |
90 91 92 93 94 95 0 0 0 99 100 101 102 103 104 | |
105 0 0 0 0 0 0 0 0 114 115 116 117 118 119 | |
120 121 122 123 124 125 0 0 0 129 130 131 132 133 134 | |
0 0 0 0 0 0 141 0 143 0 0 0 0 0 0 | |
0 0 0 0 0 0 156 0 158 0 0 0 0 0 0 | |
0 0 0 0 0 0 171 0 173 0 0 0 0 0 0 | |
0 0 0 0 0 0 186 0 188 0 0 0 0 0 0 | |
0 0 0 0 0 0 201 0 203 0 0 0 0 0 0 | |
0 0 0 0 0 0 216 217 218 0 0 0 0 0 0 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment