[Intermediate] Interactive batching


#1

In this setup you will create a series a blue batches: a few blue balls, a red ball, a few blue balls, a red ball, etc. You will interactively determine the size of each blue batch. The maximum batch size is three, a constraint to be enforced by the system.

More specifically:

  • Initial board: https://www.lodev.org/jstumble/?board=zzzzfeeafergaeex
    image
  • Start by releasing a blue ball
  • While the ball is falling, you can select the next ball to be released, using the switch at the bottom of the board: When it points left, it will release a blue ball. When it points right, it will release a red ball. After use, the switch auto—resets to point left
  • Conplete the system so that it enforces the maximum batch size. If the fourth successive blue ball is released, the sequence should terminate.

Example:

  • Release a blue ball
  • It falls through the switch => B
  • Next blue ball is released
  • Set the switch to Right
  • Ball falls through the switch, which resets => BB
  • A red ball is released
  • It falls through the switch => RBB
  • A blue ball is released
  • It falls through the switch => BRBB
  • Next blue ball is released
  • It falls through the switch => BBRBB
  • Next blue ball is released
  • It falls through the switch => BBBRBB
  • Next blue ball is released
  • It is intercepted. The sequence terminates

So another possible sequence is the following:
BBBRBRBBRRBBRBBBRBRBBB
Note, empty batches (two consecutive red balls) are allowed.


#3

Here’s my solution.

https://www.lodev.org/jstumble/?board=rlelbeerbglfbgrfllaeerragleeraglfrxfeaifrgaeex_16_18


#4

That looks right, except that in your url the starting position of the second bit is not correct, but that’s just presumably because you created it after some testing. Here’s the fixed url: https://www.lodev.org/jstumble/?board=rlelbeerbglfbgrfllbeerrbgleerbglfrxfeaifrgaeex

Btw, your solution is quite similar to mine: https://www.lodev.org/jstumble/?board=rleagaeelxgaeerrxfagareeirgalfrlfelfeafergaeex

I hope you liked the problem. I could have also called it “resettable counter”, but I figured I’d give it an interactive twist. That also solved the problem of otherwise having to intercept all balls.


#5

Oh yeah, sorry about the error.