Last active
October 28, 2020 11:58
-
-
Save wildonion/b422d8e6ab2912c4b9ac5cdcb63b9b7f to your computer and use it in GitHub Desktop.
topol algo __ subset combination problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Callable | |
# topol algo | |
tsbst: list = [None] | |
def subset(sett: list) -> list: | |
biN:Callable[str, str] = lambda el : ''.join(reversed([str((el>>i) & 1) for i in range(len(sett))])) | |
tpx:int = 2**len(sett) | |
for i in range(1,tpx): | |
# breakpoint() | |
# print(list(biN(i%tpx))) | |
yield [i for i,j in zip(sett, list(biN(i%tpx))) if int(bool(i)) is int(j)] | |
# subset((lambda x : [input() for n in range(int(input("[+] NUMBER OF MEMBER SET : ")))])([])) | |
for sbst in subset(sys.argv[1].split(",")): | |
tsbst.append(set(sbst)) | |
smallestTopol: set = [None, tsbst[len(tsbst)-1]] | |
largestTopol: list = tsbst | |
print(f"\n[+] THE LARGEST TOPOLOGY IS\n\n\t {largestTopol}\n") | |
print(f"[+] THE SMALLEST TOPOLOGY IS\n\n\t {smallestTopol}\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment