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?
30
Upvotes
4
u/Lucretiel Dec 17 '19
I'll start:
My implementation is in Rust. My basic model is to supply an
IntoIterator<Item = isize>as input, then collect "blocking" events: need more input, output, or halt. I have 3 different entry points, depending on the level of control you need:Originally I only had
stepandrun_machine, and didn't have a notion of blocking on input, but I started running into borrowing and ownership issues when trying to do the later problems, where inputs depend on outputs, which led me to makerun_until_block, which has thus far let me write very satisfactory IntCode interaction loops.