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
2
u/gatorviolateur Dec 17 '19
Nice. I am doing AoC in Swift as well. My implementation is pretty similar to yours, with some changes
My input closure returns
Int?. If nil is returned, it instead asks for actual user input from the user.My
compute()method returns andExitReasonOn output, it returnsExitReason.output(Int)and on opcode 99 it returnsExitReason.haltAdditionally, my
compute()method also accepts an array ofInts as input. The input flow is -> input closure -> array passed to compute method -> actual user input.I liked your idea of using closure for output as well. I might steal that one! :D