From ed8118ae084914cec4cb083634e575145e576ccb Mon Sep 17 00:00:00 2001 From: vincent Date: Tue, 15 Nov 2022 19:03:29 +0100 Subject: [PATCH] implement recursice function --- fenetre.py | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/fenetre.py b/fenetre.py index bf09146..f6b426b 100644 --- a/fenetre.py +++ b/fenetre.py @@ -1,6 +1,6 @@ # Charger les bibliothèques DesignScript et Standard Python import sys -import clr +# import clr import re # clr.AddReference('ProtoGeometry') @@ -9,16 +9,19 @@ import re Keylist = [ - "RSV12", - "RSV13", - "RSV16", - "RSV19", - "RSV20,RSV21,RSV1", + "rsv12", + "rsv13", + "rsv16", + "rsv19", + "rsv20", + "rsv21", + "rsv1", ] # dataEnteringNode[0] CollittionList = [ ["rsv13"], ["rsv12", "rsv16"], - ["rsv20", "rsv21", "rsv1"], + ["rsv13"], + ["rsv20","rsv21","rsv1"], ["rsv19", "rsv1"], ["rsv19"], ["rsv19", "rsv20"], @@ -26,3 +29,24 @@ CollittionList = [ OUT = [] +def find_in_out(rsv, out): + for arr in OUT: + if rsv in arr: + return True + + +def recurCollition(index, OUTindex): + for i in CollittionList[index]: + if not find_in_out(i, OUT): + OUT[OUTindex].append(i) + recurCollition(Keylist.index(i), OUTindex) + + +for i in range(len(Keylist)): + if find_in_out(Keylist[i], OUT): + continue + OUT.append([Keylist[i]]) + recurCollition(i, len(OUT) - 1) + + +print(OUT)