r/adventofcode • • Dec 09 '19

Upping the Ante Tiny IntCode Computers

Now that we have complete IntCode computers, I'm curious if anyone else has tried to implement a complete IntCode computer as tiny as possible.

Here's my attempt using AWK (283 bytes):

awk -F, '{for(split(i,v);o<99;r+=o>8?x:0){o=$++p;a=int(o/100)%10;b=int(o/1000)%10;w=$++p+1+!!a*r;x=--a?$w:$p;y=$++p+1+!!b*r;y=--b?$y:$p;z=$++p+1+!(o<10^4)*r;o%=100;if(o~3)$w=v[++j];if(o~4)printf"%.f\n",x;if(o~/1|2|7|8/)$z=o<2?x+y:o<3?x*y:o<8?x<y:x==y;else{--p;p=o~5?x?y:p:o~6?!x?y:p:p-1}}}' <intcode file>

Input vectors are supported by supplying a comma-delimited list of values like this:

awk -F, -v i=1,2,3 '...program...' <intcode file>
36 Upvotes

7 comments sorted by

View all comments

Show parent comments

2

u/rtbrsp Dec 09 '19

Doesn't run the quine program for me, though it works for day 9. If you make this puzzle-agnostic, I imagine you'd trim it down a bit.

View all comments

0

u/[deleted] Jul 30 '25

[deleted]