From cbc3ebfca24c89c475b9970fa525055d8291ee88 Mon Sep 17 00:00:00 2001 From: Emmanuel Gaillot Date: Sat, 20 Dec 2025 22:43:00 +0100 Subject: Loop until failing one challenge --- lambda-calcul/javascript/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lambda-calcul/javascript/index.js') diff --git a/lambda-calcul/javascript/index.js b/lambda-calcul/javascript/index.js index d8b5e68..ef77fea 100644 --- a/lambda-calcul/javascript/index.js +++ b/lambda-calcul/javascript/index.js @@ -16,7 +16,8 @@ const solveNextChallenge = (token) => client .then(challenge => console.log(`Next challenge: ${challenge}`) || challenge) .then(client.solve) .then(solution => console.log(`Posting solution: ${solution}`) || solution) - .then(solution => client.postSolution(token, solution)); + .then(solution => client.postSolution(token, solution)) + .then(() => solveNextChallenge(token)); const waitForEnterToBePressed = () => { const readlineInterface = createInterface({ @@ -24,7 +25,7 @@ const waitForEnterToBePressed = () => { output: process.stdout, }); - return readlineInterface.question(`Done. Press Enter to unregister ${playerName}.`) + return readlineInterface.question(`Press Enter to unregister ${playerName}.`) .then(() => readlineInterface.close()); }; @@ -34,6 +35,7 @@ client.start() console.log(`${playerName} has registered with token ${t}`); }) .then(() => solveNextChallenge(token)) + .catch(() => console.log("Oops!… Didn't get this one.")) .then(() => waitForEnterToBePressed()) .then(() => client.unregister(token)) .then(() => console.log(`${playerName} unregistered!`)); -- cgit v1.3.1