Lights game - hard

Create a mini-game where pressing a button toggles lights. This is an extended version of the easy problem with a button that suggests a move.

Requirements:

  • There are 6 lights from A - F and 5 buttons from 1 to 5.
  • By default, the lights should be off.
  • Pressing the following button should toggle the following lights:
    buttonlights
    1B, E
    2B, C, D
    3A, F
    4E
    5A, B, F
    You can use a toggleMap variable provided in the code.
  • If the light is on, add an active class.
  • If the light is off, remove an active class.
  • Clicking the suggest button should suggest the next move to solve the game (all lights are on). Add an active class to the suggested button. The suggested sequence should be as short as possible.
  • If multiple buttons (sequence) must be pressed to solve the game, suggest the button with the lowest number.
    For example, pressing buttons 2, 3, 4 turn on all lights. The suggested button should be 2.
  • If there are multiple different sequences (2, 3 or 4, 5), pick a sequence that starts with the lowest number (2, 3).
  • If all lights are on, disable the suggest button.

You are free to add classes, styles, ids, but don't edit or remove data-test attributes.
Create an account to start coding
Create account