From 070a72162ce833436316fe8ab56a90cd51525eb2 Mon Sep 17 00:00:00 2001 From: "aurian.jault" Date: Mon, 3 Apr 2023 10:31:39 +0200 Subject: [PATCH 1/2] update Checkqttriutes --- src/algo.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/algo.js b/src/algo.js index 8f0ab21..b5c09d6 100644 --- a/src/algo.js +++ b/src/algo.js @@ -14,7 +14,7 @@ function isSet(cards) for(let j = 0; j < attributesMatrix.length; j++) { listAttributes.push(attributesMatrix[j][i]); } - if(!checkAttributes(listAttributes)){ + if(!checkAttributes2(listAttributes,attributesMatrix.length)){ return false; } } @@ -22,6 +22,16 @@ function isSet(cards) } +function checkAttributes2(params,length) { + var tab = [] + params.forEach(element => { + if (!tab.includes(element)) { + tab.push(element) + } + }); + return tab.length === 1 || tab.length === length; +} + function checkAttributes(attributes){ let orderingMethod = "null"; // Can only take ["null", "same", "different"] let boolLoop = true; From 9e4e206b598ad738c38d84f5231f94ec7ef0f41b Mon Sep 17 00:00:00 2001 From: "aurian.jault" Date: Mon, 3 Apr 2023 10:49:12 +0200 Subject: [PATCH 2/2] opti checkattributes --- src/algo.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/algo.js b/src/algo.js index 4ebf3e1..7792ee3 100755 --- a/src/algo.js +++ b/src/algo.js @@ -14,6 +14,8 @@ function isSet(cards) for(let j = 0; j < attributesMatrix.length; j++) { listAttributes.push(attributesMatrix[j][i]); } + console.log("JE SUIS LES ATTRIBUTS") + console.log(listAttributes) if(!checkAttributes2(listAttributes,attributesMatrix.length)){ return false; } @@ -30,6 +32,7 @@ function checkAttributes2(params,length) { tab.push(element) } }); + console.log(tab.length === 1 || tab.length === length) return tab.length === 1 || tab.length === length; }