From 8a953d63ef59a4b30325da190174ebef09a5e32d Mon Sep 17 00:00:00 2001 From: "aurian.jault" Date: Tue, 31 Jan 2023 17:23:50 +0100 Subject: [PATCH 1/3] pseudo code du 1er algo --- src/algo.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/algo.js diff --git a/src/algo.js b/src/algo.js new file mode 100644 index 0000000..db0090e --- /dev/null +++ b/src/algo.js @@ -0,0 +1,18 @@ +// Pseudo code +// +/* + * function checkReslt(array ) + * { + * new array> matrice = vide + * + * forEach(array: value) + * { + * matrice.add(value.getAttrib) + * } + * Check all length of matrice + * for(i = 0; i Date: Thu, 2 Feb 2023 11:06:14 +0100 Subject: [PATCH 2/3] Algo de verification --- src/algo.js | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/src/algo.js b/src/algo.js index db0090e..07b58fc 100644 --- a/src/algo.js +++ b/src/algo.js @@ -11,8 +11,80 @@ * } * Check all length of matrice * for(i = 0; i tab + * for (j=0; j { + matrice.push(element.getAttribute()); + }); + // Idéalement check si toute les listes d'attributs sont de même taille + for (let i = 0; i < matrice[0]; i++) { + let listAttrib = [] + for (let j = 0; j < matrice[i]; j++) { + listAttrib.push(j); + } + if(!checkattrib(j)){ + return false; + } + return true; + } +} + + +function checkattrib(attribs){ + let orderingMethod = "null"; // Can only take ["null", "same", "different"] + attribs.forEach(function callback(value, index) + { + if(!index === attribs.length) + { + for (let i = index+1; i < array.length; i++) + { + if(attribs[i] === value) + { + if(orderingMethod === "null" || orderingMethod === "same") + { + orderingMethod = "same"; + } + else + { + return false; + } + } + else + { + if(orderingMethod === "null" || orderingMethod === "different") + { + orderingMethod = "different" + } + else + { + return false + } + } + + } + } + }); + return true; +} From 6891a8bbdbc4d68078933c0d17f4b801913f77e5 Mon Sep 17 00:00:00 2001 From: "aurian.jault" Date: Fri, 3 Feb 2023 13:29:48 +0100 Subject: [PATCH 3/3] Fin algo de verification des set --- src/algo.js | 62 ++++++++++++++++++++++++++++++++++---------------- src/index.html | 20 ++++++++++++++++ 2 files changed, 62 insertions(+), 20 deletions(-) create mode 100644 src/index.html diff --git a/src/algo.js b/src/algo.js index 07b58fc..c4e8740 100644 --- a/src/algo.js +++ b/src/algo.js @@ -23,44 +23,66 @@ * } * * - * */ + * */ + + function main() { // "Stub de test" + let card1 = new Card("Purple","1","Triangle","Full"); + let card2 = new Card("Purple","2","Triangle","Full"); + let card3 = new Card("Purple","3","Triangle","Full"); + let card8 = new Card("Purple","4","Triangle","Full"); + let card9 = new Card("Purple","5","Triangle","Full"); + let card0 = new Card("Purple","6","Triangle","Full"); + let card10 = new Card("Purple","7","Triangle","Full"); + let card4 = new Card("Purple","1","Triangle","Full"); + let card5 = new Card("Purple","2","Triangle","Full"); + let card6 = new Card("Purple","1","Triangle","Full"); + console.group("TEST TRUE") + if(isSet([card1,card2,card3,card8,card9,card0,card10])) + { + console.log("TRUE") + } + else + { + console.log("FALSE") + } + console.groupEnd() } -function isSet(card) +function isSet(cards) { - let matrice = []; + let attributesMatrix = []; - card.forEach(element => { - matrice.push(element.getAttribute()); + cards.forEach(element => { + attributesMatrix.push(element.getAttributes()); }); // Idéalement check si toute les listes d'attributs sont de même taille - for (let i = 0; i < matrice[0]; i++) { - let listAttrib = [] - for (let j = 0; j < matrice[i]; j++) { - listAttrib.push(j); + for(let i = 0; i < attributesMatrix[0].length; i++) { + let listAttributes = [] + for(let j = 0; j < attributesMatrix.length; j++) { + listAttributes.push(attributesMatrix[j][i]); } - if(!checkattrib(j)){ + if(!checkAttributes(listAttributes)){ return false; } - return true; } + return true; } -function checkattrib(attribs){ +function checkAttributes(attributes){ let orderingMethod = "null"; // Can only take ["null", "same", "different"] - attribs.forEach(function callback(value, index) - { - if(!index === attribs.length) + let boolLoop = true; + attributes.forEach((value, index) => { + if(index !== attributes.length) { - for (let i = index+1; i < array.length; i++) + for (let i = index+1; i < attributes.length; i++) { - if(attribs[i] === value) + if(attributes[i] === value) { if(orderingMethod === "null" || orderingMethod === "same") { @@ -68,7 +90,7 @@ function checkattrib(attribs){ } else { - return false; + boolLoop = false; } } else @@ -79,12 +101,12 @@ function checkattrib(attribs){ } else { - return false + boolLoop = false } } } } }); - return true; + return boolLoop === true; } diff --git a/src/index.html b/src/index.html new file mode 100644 index 0000000..b32303c --- /dev/null +++ b/src/index.html @@ -0,0 +1,20 @@ + + + + + + My awesome blog + + + +

My awesome blog

+ + + + + + + + \ No newline at end of file