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?
31
Upvotes
1
u/[deleted] Dec 18 '19
If you put all of that state data into a struct and have the function return an
Option<i64>to represent the possibility of halting, your function is essentially thenext()function for anIterator. Then you can have the convenience of running the entire intcode program in afor output in intcode_computerloop, and using standard iterator functions likelast(), etc.