-
-
Save jsn/04b076a359d9b5fd739ebb0dc2af4c9f 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 <stdlib.h> | |
#define N 26 | |
#define LEN (N * 2 + 1) | |
static int s[LEN] ; | |
static void print_s(void) { | |
for (int i = 0; i < LEN; i ++) | |
printf("%c", s[i] == 1 ? '-' : (s[i] - 3 + 'A')) ; | |
puts("") ; | |
exit(0) ; | |
} | |
static int add_char(char c, unsigned i) { | |
int i2 = i + c - 1 ; | |
if (s[i] == 0 && s[i2] == 0) { | |
s[i] = s[i2] = c ; | |
return 0 ; | |
} | |
return -1 ; | |
} | |
static void del_char(char c, unsigned i) { | |
s[i] = s[i + c - 1] = 0 ; | |
} | |
#define X(n, Q) \ | |
for (int i##n = !n; i##n < LEN - n; i##n ++) \ | |
if (add_char(n + 1, i##n) == 0) { \ | |
Q ; \ | |
del_char(n + 1, i##n) ; \ | |
} | |
int main(int ac, const char *av[]) { | |
X(0, X(27, X(26, X(25, X(24, X(23, X(22, X(21, X(20, X(19, X(18, X(17, X(16, X(15, X(14, X(13, X(12, X(11, X(10, X(9, X(8, X(7, X(6, X(5, X(4, X(3, X(2, print_s()))))))))))))))))))))))))))) ; | |
return 0 ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment