Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions backtracking/all_combinations.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@ def generate_all_combinations(n: int, k: int) -> [[int]]:
return result


#creating all state for the list

def create_all_state(increment, total_number, level, current_list, total_list):
if level == 0:
total_list.append(current_list[:])
return

#looping through total and increment
for i in range(increment, total_number - level + 2):
current_list.append(i)
create_all_state(i + 1, total_number, level - 1, current_list, total_list)
current_list.pop()


#printing the state
def print_all_state(total_list):
for i in total_list:
print(*i)
Expand Down