Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| #!/usr/bin/python2 | |
| # Copyright (C) 2016 Sixten Bergman | |
| # License WTFPL | |
| # | |
| # This program is free software. It comes without any warranty, to the extent | |
| # permitted by applicable law. | |
| # You can redistribute it and/or modify it under the terms of the Do What The | |
| # Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See |