How to approach simple recursion in python -


i've been trying understand recursion/recursivity in programming languages , i've chosen work python, since it's language understand most. i've tried resolving following problem -

given 3 different lists of elements, find possible patterns person has followed during shopping day.

lists

purchases = [[money_spent, time0], [money_spent, time1], [money_spent, time3]]  time_between_shops = [[time_to_self, time_to_shop2, time_to_shop3, time_to_shop4],                      [time_to_shop1, time_to_self, time_to_shop3, time_to_shop4],                      [time_to_shop1, time_to_shop2, time_to_self, time_to_shop4],                      [time_to_shop1, time_to_shop2, time_to_shop3, time_to_self]]  list_of_products = [["shop1", {"product1": price_of_product1, "product2": price_of_product2}],                     ["shop2", {"product3": price_of_product3, "product4": price_of_product4, "product5": price_of_product5}],                     ["shop3", {"product6": price_of_product6}],                     ["shop4", {"product7": price_of_product7}]] 

in lists purchases ordered time (earliest latest purchase) , shops have same indexes in list_of_products in time_between_shops. time between shops can same, time takes go shop shop b can different time takes go shop b shop a. given time in minutes 0 0:00 , 1439 23:59.

given information, know how approach problem regular way, need use recursive methods obtain possibilities. i've read on recursive methods, know represent, , when see 1 can understand , how works, when comes creating recursive methods on own, lost since go regular methods.

so how should approach problem in order resolve using recursion instead of regular methods?


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -