2
1
Fork 0

Day 19: Add obfuscated C

This commit is contained in:
Mia Herkt 2021-12-20 21:56:52 +01:00
parent 43356e90d8
commit 6b8b9ea6ed
Signed by: mia
GPG Key ID: 72E154B8622EC191
1 changed files with 50 additions and 0 deletions

50
19/art.c Normal file
View File

@ -0,0 +1,50 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
typedef
#define U realloc
#define r(n,a,b,c) \
case n :return(B){a ,b,c}
struct B{int x,y,z ;}B;inline static
B S( B a,B b){ return(B){a. x-b.x,a.y-
b. y ,a.z-b.z};} typedef struct Q{int c,e;B*
R; }Q;inline static int M( B a,B b){ return abs(a.x-b.
x)+abs(a.y-b .y)+abs(a.z- b.z);}const size_t Z= sizeof(B)
,q=sizeof (Q);inline static B T(B b,int i){int x=b.x,y=b.y ,z=b.z;
switch(i){r( 0,x,y,z);r( 1,x,-y,-z);r (2,x,z,-y);r (3,x,-z,y);r (4,y,x,-z
);r( 5,y,-x,z); r(6,y,z,x);r (7,y,-z,-x); r(8,z,x,y);r (9,z,-x,-y );r(
10,z ,y,-x);r(11,z,-y,x) ;r(12,-x,y,- z);r(13,-x, -y,z);r(14 ,-x,
z,y) ;r(15,-x ,-z,-y);r( 16,-y,x,z);r( 17,-y,-x,-z );r(
18, -y,z,-x);r(19 ,-y,-z,x);r( 20,-z,x,-y );r(
21,- z,-x,y) ;r(22,-z,y,x );r(23,- z,-
y,- x);} return(B){0};} int
main (){Q*E=NULL;getchar(); int
n,e =1,I=0,G =0,i
=0, j,m ;while (scanf ("-"
"- " "scanner " "%d " "---\n" ,&n
)== 1){n++;E=U(E,n *q );Q* s =& E[ n-1];s ->R=
NULL ;s->c =1;s ->e=n== 1;B b;while (scanf (""""
"%i" ",%i," "%i", & b.x, &b.y,&b. z)==3) {s->R =U(s
->R ,++s ->c *Z) ; s -> R[s ->c-1 ]=b;I++;} scanf( "%*""[" "^-"
"]" );memset(&s-> R[0],0 ,Z);}B *W;W =malloc( I*Z);I= E[0].c;memcpy(W,E [0].
R,I *Z);while(e<n ) for( int i= 0;i< n;i++) for(int m=0 ;m< 24;m++){ int r
,y, u,o,p ,a, d,f,g; if(!E[ i].e )for(r =0; r< I;r++) for(y
=1; y<E[i ].c;y ++){g= 0;B D=S(T( E[i].R [y],m), W[r]
) ; for(u =1;u<E [i].c; u++) {B c=S (T(E[i ].R[u], m),D
) ; for(o =0;o<I ;o ++) if(! memcmp (&c,&W [o],Z)) {g++
;if (g >= 12){ { B Y[E[ i].c -1];p= 0;for( a=1;a< E[i] .c;a
++) { B t=S( T(E[i] .R[a ],m),D );f=0; for(d= 0;d<
I;d ++)if(! memcmp ( &t ,& W[d ],Z )) { f++;
break ;}if( !f ) Y [ p ++]=t;} memcpy (W+I
,Y,p *Z);I+= p;E[i] .R[0 ]=(B){-D. x,-D
.y,-D. z};E[i].e= 1;e ++;
printf("" "%d/" "%d\n",
e, n);} goto X;}}}}X:
}for(;i< n;i ++)for(j=
0;j<n;j ++){ m=M(E[i]
.R[0],E[ j].R [0]);if(
m>G) G= m ;} printf(""
"Silver: %d\nGold: %d\n",I
-1,G) ;}