From c12d2c2b27328dba944bc849a3c14167ba81ee07 Mon Sep 17 00:00:00 2001 From: Noe GARNIER Date: Mon, 10 Oct 2022 11:27:16 +0200 Subject: [PATCH] =?UTF-8?q?mise=20=C3=A0=20jour=20de=20palindrome.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- brythonRunner/javascript/palindrome.js | 30 ++++++++++++++++---------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/brythonRunner/javascript/palindrome.js b/brythonRunner/javascript/palindrome.js index 3751b973..ba76c856 100644 --- a/brythonRunner/javascript/palindrome.js +++ b/brythonRunner/javascript/palindrome.js @@ -1,3 +1,7 @@ +function Abort() +{ + throw new Error('This is not an error. This is just to abort javascript'); +} function run() { const console = document.getElementById("console"); @@ -34,13 +38,13 @@ function run_init() { if (document.getElementById("console") != '') { document.getElementById("console").innerHTML = ''; run(); - // setTimeout(() => {console.log("Resolve while pb")}, 1000); - // setTimeout(() => {location.reload();}, 1000); + //setTimeout(() => {console.log("Resolve while pb")}, 1000); + //setTimeout(() => {Abort()}, 5000); } else { run(); - // setTimeout(() => {console.log("Resolve while pb")}, 1000); - // setTimeout(() => {location.reload();}, 1000); + //setTimeout(() => {console.log("Resolve while pb")}, 1000); + //setTimeout(() => {Abort()}, 5000); } } @@ -100,9 +104,6 @@ function exec(code, id) { //~ Function that check if the code in the editor as the same result as the solution. function check(){ - console.log(retourSolution) - console.log(retourCode) - console.log(retourSolution == retourCode) if (retourSolution == "ERROR") { result.innerHTML = "Il semblerait qu'il y a une erreur dans ton code :/"; result.classList.remove('hidden'); @@ -130,12 +131,19 @@ def estPalindromeVerif(var): return False def testPalindrome(x): + l=[1,2,3,2,1] + if(estPalindrome(l)==False): + return False + l=[9,5,7,7,9] + if(estPalindrome(l)==True): + return False l=[] for i in range(x): - for j in range(r.randint(1,10)): - l.append(r.randint(0,9)) - if(estPalindrome(l)!=estPalindromeVerif(l)): - return False + for j in range(r.randint(1,10)): + l.append(r.randint(0,9)) + if(estPalindromeVerif(l)!=estPalindrome(l)): + return False + l=[] return True print(testPalindrome(5))