Skip to content

Instantly share code, notes, and snippets.

@dreisicht
Created March 14, 2022 17:45
Show Gist options
  • Save dreisicht/52baa8b273e0ce06ea6a49cbeeb94cd8 to your computer and use it in GitHub Desktop.
Save dreisicht/52baa8b273e0ce06ea6a49cbeeb94cd8 to your computer and use it in GitHub Desktop.
def get_according_elements(list_ipt):
list_of_results = []
for base_el in range(len(list_ipt)):
if list_ipt[base_el] < 0:
continue
for el2 in range(len(list_ipt)):
if list_ipt[el2] > 0 or base_el == el2:
continue
if list_ipt[base_el] + list_ipt[el2] == 0:
list_of_results.append([list_ipt[base_el], list_ipt[el2]])
for el3 in range(len(list_ipt)):
if list_ipt[el3] > 0 or el2 == el3:
continue
if list_ipt[base_el] + list_ipt[el2] + list_ipt[el3] == 0:
list_of_results.append([list_ipt[base_el], list_ipt[el2], list_ipt[el3]])
for el4 in range(len(list_ipt)):
print(base_el, el2, el3, el4)
if list_ipt[el4] > 0 or el3 == el4:
continue
if list_ipt[base_el] + list_ipt[el2] + list_ipt[el3] + list_ipt[el4] == 0:
list_of_results.append([list_ipt[base_el], list_ipt[el2], list_ipt[el3], list_ipt[el4]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment