Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## This is my procedural way. For some reason this results in kernel death. Why?
- def merge_lists(list_of_lists):
- single_list = []
- for individual_list in list_of_lists:
- for entry in individual_list:
- single_list.append(entry)
- return single_list
- def planner(k):
- plan = [[1]]
- if k > 1:
- while k not in merge_lists(plan):
- for individual_list in plan:
- temp = list(individual_list)
- for entry in individual_list:
- temp2 = list(temp)
- temp2.append(temp[-1] + entry)
- plan.append(temp2)
- plan_optimal = []
- for individal_list in plan:
- if k in individual_list:
- plan_optimal.append(individual_list)
- return plan_optimal
- if k == 1:
- return plan
- print(planner(2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement