← go back

return true to win

const {RegExp} = window;
Object.freeze(Array.prototype);
Object.freeze(RegExp.prototype);
Object.freeze(String.prototype);

const randomInt = () => Math.floor(Math.random() * 1000);
const testCases = [...Array(1000)].map(() => Math.random() > .5 ? [x = randomInt(), x, x] : [...Array(3)].map(randomInt))

function irregExp(x) {
  const regex = RegExp(x);
  return testCases.every((test) => regex.test("a".repeat(test[0])+"b".repeat(test[1])+"c".repeat(test[2])) === (test[0] === test[1] && test[1] === test[2]))
}
Sep 13, 2022, 3:17 AM
2 0 0

Comments