2
1
Fork 0

Day 14: Add obfuscated C solution

This commit is contained in:
Mia Herkt 2021-12-14 22:35:27 +01:00
parent d269a2a840
commit 4a6bfff4c0
Signed by: mia
GPG Key ID: 72E154B8622EC191
1 changed files with 24 additions and 0 deletions

24
14/obf.c Normal file
View File

@ -0,0 +1,24 @@
#include <stdio.h>
#include <string.h>
enum{M
#define\
P(a,\
b) (\
((a-\
65)<<\
6)|(b-65))
=P(90,90)+1};
size_t C[M]={0},T[M];void p(char*s){size_t r= -1,
R=0,k,n,i;for(i=65;i<90+1;i++){k=P(i,98);if((n=C[k])){if (n<r)
r= n;else if(n>R)R=n;}}printf("%s: %lu\n",s,R-r);}int main( void){
size_t i,j,n,k;char t[128],R[128][3]={0};scanf("%127[A-Z]\n",t) ;for(
i=0;t[i]/*⁻⁻*/;i++){if(i)/*⁻⁻*/C[P(t[i-1],t[i])]++;C[P(t[i],98)]++;}
for(i=0/* */;scanf(/* */"%c%c -> %c\n",&R[i][0],&R[i][1],&R[i
][2])==/* */3;i++);/* */for(i=0;i<40;i++){memset(T,0,M*sizeof
(size_t))/*₋₋*/;for(j=0;R[/*₋₋*/j][0];j++){k=P(R[j][0],R[j][1]);if((n=C
[k])){C[k]=0;C[P(R[j][2],98)]+=n;T[/*⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻*/P(R[j][0],R[j][
2])]+=n;T[P(R[j][2],R[j][1])]+=n;}}/* MADE IN CHINA */for(j=0; R[j][
0];j++){k=P(R[j][0],R[j][2]);C[k]/*₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋*/=T[k]; k=P(R
[j][2],R[j][1]);C[k]=T[k];}if(i==9)p("Silver");}p("G" "old"
);}