r1cc4rdo / daily_coding_problem

Solutions to https://dailycodingproblem.com
The Unlicense
160 stars 39 forks source link

Rmpr patch coding problem 50 #7

Closed RMPR closed 6 years ago

RMPR commented 6 years ago

I represent binary tree with a table, since there is no pointers in python, The matter of this solution is that the tree need to be complete or almost complete, suggestions are welcomed.

r1cc4rdo commented 6 years ago

Hi there. Thanks for the PR :) Did you actually receive this problem from http://dailycodingproblem.com? This was not in the set I received. If yes, happy to pull if you use the same format I used everywhere else (doctesting and single self-contained function).

r1cc4rdo commented 6 years ago

Regarding representing a tree, I would use nested tuples. So instead of ['*', '+', '+', 3, 2, 4, 5], using something like ('*', ('+', 3, 2), ('+', 4, 5)). See for reference problems 8, 36, 48.

RMPR commented 6 years ago

Hello Riccardo, I received my problems from https://www.dailycodingproblem.com/ it's a mailing list, so one problem per day, I got your point with nested tuples, but I was just trying to be memory efficient. I'll check the reference problems and come back to you. Regards.

r1cc4rdo commented 6 years ago

Closing after a week. I've added my own solution to the repository, have a look!