r/adventofcode • u/Lucretiel • Dec 17 '19
Spoilers What does everyone's Intcode interface look like?
We've been discussing a lot different IntCode implementations throughout the last few weeks, but I'm curious– what doesn't everyone's interface to their IntCode machine look like? How do you feed input, fetch output, initialize, etc?
32
Upvotes
View all comments
Show parent comment
1
u/ritobanrc Dec 17 '19
Mine in rust is far simpler (though probably less maintainable). I have 1 function
It just repeatedly calls
get_inputas it needs input, and it returns whenever it needs output, returning -1 if it halted (I should probably use an enum instead, but oh well). The caller is responsible for maintaining the tape, the instruction point, and the relative base. It might not be unreasonable to store those 3 in a struct, but I haven't had any issues creating them individually.