Agent-Hellboy / trace-dkey

Python library to trace path of a particular key inside a nested dict
MIT License
7 stars 5 forks source link

Recursive function should return path instead of printing the path #1

Closed Agent-Hellboy closed 2 years ago

Agent-Hellboy commented 2 years ago

https://github.com/Agent-Hellboy/trace-dkey/blob/8448f16325c3a7d5d24d0feb05ab36d2a4e84fc7/src/trace_dkey/__init__.py#L13 This function should return the path of the key instead of printing in the mid

we can take inspiration from the following 2 problems of leetcode https://leetcode.com/problems/count-good-nodes-in-binary-tree/ https://leetcode.com/problems/path-sum/

This is tricky as the key can be present inside 2 subdict
maybe this can be an extension to an approach of above 2 question

zluipaiva commented 2 years ago

Hey, I would like to work on this

Agent-Hellboy commented 2 years ago

Sure, go ahead

Agent-Hellboy commented 2 years ago

any update @zluipaiva , As currently unit test is very weird https://github.com/Agent-Hellboy/trace-dkey/pull/6

zluipaiva commented 2 years ago

any update @zluipaiva , As currently unit test is very weird #6

Sorry for the delay My idea is to have an array of paths that gets updated every time the key is found, and then we return this array. I implemented it but have to fix some things, I'll try to finish it today