Skip to main content

All Questions

Tagged with
5 votes
1 answer
915 views

Python: wild card pattern matching with memoization

Here is my take on wild card pattern matching with memoization. I would appreciate comments on clarity of the code, as well as suggested ways to improve readability and maintainability (for bigger ...
CIsForCookies's user avatar
4 votes
2 answers
3k views

Memoization with factorial in Python

I wrote a Python module to learn about memoization, and I have some questions on what I did. How pythonic is this? Does it make a difference if I used a class attribute instead of a function attribute ...
BusyAnt's user avatar
  • 639
2 votes
1 answer
105 views

Optimally allocating a resource with time-varying demand and cost

I'm working on the following DP which finds the optimal way to allocate a resource. At each time step I can either allocate (0.2 resources) at cost C or not in which case the storage is reduced by the ...
ic_fl2's user avatar
  • 123
4 votes
1 answer
823 views

Universal memoization decorator

I've just written a simple caching / memoization python decorator. It's purpose is to cache what the function returns for all the arguments combinations it's been ever invoked with. So, if, say, we ...
rroszkowiak's user avatar