3 ms·
Here is an easy (or extremely hard) problem. Build a 2d grid with two objects. A chest and a hopper. Chests and hoppers are containers that hold up to 64 items
by imtringued 6y ago
Here is an easy (or extremely hard) problem.
Build a 2d grid with two objects. A chest and a hopper. Chests and hoppers are containers that hold up to 64 items. When a hopper (they can point in 4 directions) is pointing at a chest it will insert its inventory into the chest, until the chest is full (one item at a time). If there is a chest on the funnel side of the hopper then extract items from the chest and put the items into the hopper (again one item at a time). Chaining hoppers is allowed.
Now go out and enjoy multithreading hell.
Hint: through weird contortions it is possible to do this without any synchronization and keep it data parallel at the same time. If you did this in a production codebase you would be the only person on the planet that will understand the code.