I'm working on a 2019 Advent of Code challenge (day 7), so bonus if you've done it before. Basically part of the challenge requires you to be running 5 "computers" which are processing a made-up programming language. Each computer gives an output that needs to be passed to the next computer to process, and it'll keep doing this in a cycle until a certain stop condition is met.
I have made a class that generates a "computer" and have 5 instances of it running concurrently. Each instance needs to await receiving output from the the computer it's connected to. Ignore what it's being assigned to, but here's the code for the relevant line:
this.code[this.code[i + 1]] = await ampA.output()
Here's the output method if you're curious:
output(output, value1) {
output = value1
return output
}
The problem I'm having is that this is calling ampA.output(), so basically it's calling the method without giving it any arguments, which is not correct. What I want it to do is wait for ampA to arrive at it's next output, and set the variable equal to that output. Is there a way to do this? Am I even in the ballpark of doing this correct? I'm relatively new to coding, and async/await is a bit out of my depth, so it's possible this is a very incorrect approach. Any help is appreciated, and let me know if more clarification about the situation is needed!