Skip to content
Advertisement

Tag: recursion

Python: Building list of lists using dictionary recursion

I have a very complicated problem that I am sort of hoping to rubberduck here: I have a dictionary: whose structure wont always be the same (i.e., there could be further nesting or more keys in any sub-dictionary). I need to be able to generate a specifically ordered list of lists (contained sub-lists need not be ordered) based on some

Using recursion to determine the index path of a nested function

Im trying to make a function which finds a value from a list (xs) using another list (index_list) as an index path. My function should work like this: So far I have: This however just returns 0 for everything, but I don’t know what else the base case should be. Answer You’re quite close, but you forgot that at each

Python DFS nested dictionary

I’ve written a function which should be able to search a nested dictionary, using DFS, to find a specific value. The recursive element seems to be working fine, however, when the base case should return True, it simply doesn’t. And the results. As you can see, the standard output “i==i” shows that this element was evaluated correctly but the return

Advertisement