Created
February 26, 2024 11:44
-
-
Save Colk-tech/259f8f43a6c68d4dc2b4495437bf84e1 to your computer and use it in GitHub Desktop.
Show all possible magnitude relationships
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
import itertools | |
from typing import Union | |
SYMBOLS: list[str] = ["p", "q", "r", "s"] | |
if __name__ == "__main__": | |
for number_of_equals in range(0, len(SYMBOLS)): | |
for equal_combination in map( | |
lambda x: list(x), itertools.combinations(SYMBOLS, number_of_equals) | |
): | |
remaining_symbols = [ | |
symbol for symbol in SYMBOLS if symbol not in equal_combination | |
] | |
sort_equals = sorted(equal_combination) | |
permutation_groups: list[Union[list[list[str]], list[str]]] = [ | |
sort_equals, | |
remaining_symbols, | |
] | |
if [] in permutation_groups: | |
permutation_groups.remove([]) | |
for permutation in itertools.permutations(permutation_groups): | |
print(permutation) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment