DEV Community

loading...

Discussion on: Daily Challenge #285 - Jewel Thief

Collapse
256hz profile image
Abe Dolinger • Edited
const crackSafe = safe => {
  const combo = ['L0', 'L0', 'L0'];
  const directions = ['L', 'R'];

  const try = (stage, combo) => {
    const comboWorked = new Array(stage + 1).fill('click').join(' ');

    for (let i = 0; i < 100; i++) {
      directions.forEach(dir => {
        combo[stage] = `${dir}${i}`;
        if safe.unlock(combo.join('-')) === comboWorked {
          return true;
        }
      });
    }
    return false;
  };

  for (let stage = 0; stage < 3; stage++) {
    if (!try(stage, combo)) {
      return -1;
    }
  }

  return safe.open(combo);
};
Enter fullscreen mode Exit fullscreen mode

Not very dynamic but should solve for the problem as written!

Collapse
meave9786 profile image
meave9786

Nice to share the amazing blog here thanks for got it how to fix 0x800705b4 all update for seen the easily setting of issues