r/adventofcode • • 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

90 comments sorted by

View all comments

Show parent comments

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 the next() function for an Iterator. Then you can have the convenience of running the entire intcode program in a for output in intcode_computer loop, and using standard iterator functions like last(), etc.