Created
December 31, 2018 18:00
-
-
Save andydude/9cfbf75c6b3803d03877830ba343c77b to your computer and use it in GitHub Desktop.
IOCCC 2017
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> | |
#include<unistd.h> | |
typedef unsigned char*_; | |
_ s,i,z,e,O,F= | |
#include W | |
"; ; } { { { { { } { { } ; } { ; ; { } ; { { } ; } ; { { { { } { { } \ | |
; } { { { { { } { ; } { } { { } { { } { { { ; ; { { } { { } { ; } { \ | |
} { { { { { } ; } { } { { } { { { \ | |
} { ; } { } { { { { { } ; } { } { \ | |
{ { } { { } ; ; { ; ; { { } { { } \ | |
{ ; } { } { { { } { } { { { ; { { \ | |
{ } { { } { { { { } { { { { { } ; \ | |
; { ; ; { { { { { } { ; } { } { { { { { } ; ; { ; ; { { ; { ; { { { \ | |
} { } { { { ; { ; { { { ; ; { } { { { } { ; } { } { { { { { } { { { \ | |
; ; { { } { ; { { { } { } { { { ; { ; { { { ; ; { { { { { } { { { { \ | |
\ | |
} { { { { { } ; } { } { { { { { { } { { { { } ; } ; { { { } \ | |
{ { { { { } { { } { { { } { { ; { { } { ; { { { { ; { { ; { \ | |
{ { { { } } { { ; { } { { { ; ; { \ | |
{ ; { ; { } { } ; { } { } ; { ; } { { { } { ; { } \ | |
{ ; { { { } { ; } } { ; ; { { } { ; ; } { ; ; ; { \ | |
} } { { } } { ; { { } } { } } } { \ | |
; } { } } { ; } } { ; ; { } } } { \ | |
{ { { { { } } } ; ; { } { ; ; } { ; } ; } { } { } } } { } { } { } \ | |
{ ; } { ; ; { } { } } { } { ; } } } { } } } } } } ; } } } } ; { } \ | |
{ } ; } } } } ; } } } ; { { } } } ; ; } } { { } } } ; { { " ; ; ; ; | |
unsigned v,o,l,A,T,I,L,E,c,H,a,C,K,R,Z=256; char n,M[2053]; int*q; int h(_ F,int l) { for(; | |
l--&&*F; putchar(*F++)); return 0; } int r(int I,int O){ return!fprintf(O&2?stderr:stdout | |
,"%d%c",I,O&1?l:32); } int m(char O){ for(a=0; a-O&&z<e; L+=((a=*z++)==92?*z==a||* | |
z==39||*z== | |
34||*z==l?* | |
z++:a:a)==l); return a; } int d(_ e,int l){ _ F=M+Z+q[l]; _ O=M+Z+q[n=-~l]; for( | |
; l<*q&&n-l&&F<O; F+=l)for(n=0; n<l&&e[n]==F[n]; ++n); return l&&n==l?T +=--l,++K:0; } | |
int j(){ for(c=0,o=Z,O=z; z<=e&&M[c=*z++]&16; ++C,L+=c==l); for(s=z-1; z>=e; )return C-= | |
!c,c; for(a=M[c]; v&32&&c==35; )return m(l),o+2; for(; a&8; ){ for( ++o; M[c] &12; c=*z++); | |
return d(s,--z-s)?o:++o; } for(; a&4; ){ for(c=c==48&&(*z|32)==120? *++z:c; M[c]&6; c=*z++) | |
; return o+(c==46?strtod(s,(char**)&z),5:!--z^4); } for(; c==47&& (*z==c||*z==42); ){ for(; | |
c==*z++; )return m(l),o; for(m(42); z<e &&*z++-47; --z, m(42)); return o; } | |
return c==39||c==34?m(c),c:*z++==61&& a&64?c|128: a&128&&z[~0]==c?*z==61 | |
&&a&32&&c-45?++z,c|o|128:c|o:a&/* 2052 */32&&z[~0]==62?o+6:*--z?c:32; } | |
void g(int l,int O){ for(c=0; c<l; ++c)(a=M[s[c]]&16)?--I:M[s | |
[c]]&1&&M[s[c+1]]&16?--I:0, O=O ?!a:! a?++A:O; } void f(int T | |
,int F){ int n; _ o=O; for (c= v&2; H==Z; L-=!(v&2 ||o[~0] | |
-l),C-=o-O)for(H=0; o<s&& *o++ -l; ); O-=O==s &&O[~0]==l; | |
T-=T==34||T==39? g(F,1), 0:Z ; a=O==s&&s>i; for(A-=T&& | |
a&&M[O[-1]]-16,!(v&8)&& (T| c)?h(O,s-O), h(s,F):T; !T | |
++; H=Z+s[1]-42){ for( n=a ; c; c^=c)for(I+=F,g(F,n | |
),n=c=2; c<F&&s[1]==47 ; ++ c)a? (a=M[s[c]]&8)||d(s+ | |
n,c-n)&&(I-=c-++n):M[s [c] ]&8?a= n=c:a; for(c=v&2; | |
!c;A+=!a&&M[s[F]]-16&& s[1]-47)for(c=0; c<F; ++ | |
c)L-=s[c]==l; for(o=s; o>O &&*--o-l; ); C-=*o== | |
l||o==i||O[~0]==l?s-o- (*o==l):0; } } int b(int | |
l){ for(a=0; l--; a+=c- 59?c==125:-~1) for(a+=a+ | |
a; (c=* F++)== 32||c==9; ); return a; } int main ( | |
int S,char**H){ for(s=e= M+Z,q= (int*)s,e+=Z/2; *F- | |
59; *e++=*F++)for(; *F==32 ; ++F,q[++*q]=e-s); for(q[++ | |
*q]=e-s,z=M,v=b(3); v--; )for (z+= b(3),o= b(3),c=b(5); o--; | |
*z++=c); for(*++e=l=10,O=s=M+4* Z,v=b (3); v--; O[o]=b(5))o=b(5) | |
; for(O+=32,v=0; ~(a=getopt(S,H,O) ); )for(v|=s[a&31]; !(a ^~-Z >>2); ) | |
return h(U,~0); for(O+=32,a=0,o=2; c= getchar(),o<a|| (i=realloc(i ,a+=Z)),~c; | |
i[o]=c,c==l+3?v&1&&++E: c==l&&i[~-o]==92 ?--o,++L,v&1?E+=2,++A:A:++o)O ??(c??)&&!(i??(??--o | |
??)&i??(o-2??)??'63)?o-=2,E+=2,c=O??(c??):0; for(F=e,e=i+o,z=i+=2,*e=0; o=j(); v&1?f(o,a):v | |
&8?v:v&2||o-Z?~v&32&&r(o,0),h(s,a),z[-1]-l&&h(F,1):0)a=z-s,o-Z?C+=a,++A,I+=v&4&&o==-~Z?1:M[ | |
o]==1&&(M[*z]==16||!*z)?0:a:a; a=e-O; a&&v&1?f(0,a),v&8||h(O,a):a; v&2?C=e-i:0; T*=v>>2&1;R | |
=C-I-T; C+=E; return v&32?0:v&16?r(I,1):r(L,2)+r(A,2)+r(C,2)+r(I,2)+r(R,2)+r(K,2)+r(T,3); } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment