Skip to content

Instantly share code, notes, and snippets.

@wildonion
Last active October 28, 2020 11:58
Show Gist options
  • Save wildonion/b422d8e6ab2912c4b9ac5cdcb63b9b7f to your computer and use it in GitHub Desktop.
Save wildonion/b422d8e6ab2912c4b9ac5cdcb63b9b7f to your computer and use it in GitHub Desktop.
topol algo __ subset combination problem
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