The fifth problem marked the return of
Intcode machine. Now it should be extended with immediate arguments, as well as input, output, jumps and conditionals. Not being very computationally expensive it was entirely straightforward to extend the solution from by adding plumbing for inputs and outputs and adding the new opcodes.
At the end I experimented a bit with various optimizations, and I noticed that more aggressive inlining sometimes made a difference. For example inlining all the calls to
val/3 saves 6.5% of the gas. Still today’s problems would fit comfortably within a microblock with 97k/117k gas for the part 1/part 2.
My solution can be found here - good luck with your solving!