Skip to content

Instantly share code, notes, and snippets.

@Colk-tech
Created February 26, 2024 11:44
Show Gist options
  • Save Colk-tech/259f8f43a6c68d4dc2b4495437bf84e1 to your computer and use it in GitHub Desktop.
Save Colk-tech/259f8f43a6c68d4dc2b4495437bf84e1 to your computer and use it in GitHub Desktop.
Show all possible magnitude relationships
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