Skip to content

Instantly share code, notes, and snippets.

@ramiropolla
Created January 11, 2013 17:09
Show Gist options
  • Save ramiropolla/4512363 to your computer and use it in GitHub Desktop.
Save ramiropolla/4512363 to your computer and use it in GitHub Desktop.
$ sh code.sh "3:paralelepipedo;hello; this is spartaaa;"
#!/bin/sh
[ ! -f a.out ] && {
TMPFILE=`mktemp`
cat>$TMPFILE<<EOF
#define g getchar()
#define p putchar
main(){int getchar(),putchar();int n,c,s;n=g-'0';c=g;if(c!=':'){n*=10;n+=c-'0'
;c=g;}while(n--){s=0;while((c=g)!=';')s+=(c>'@'&&c<'{')?"12010000000000111100"
"00000000000011011010000000111000000000"[c-'A']-'0':0;if(s>9){if(s>99){p('0'+s
/100);s%=100;}p('0'+s/10);s%=10;}p('0'+s);p(n?';':'\n');}}
EOF
cc -xc $TMPFILE
rm $TMPFILE
}
echo $* | ./a.out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment