All Questions
Tagged with memoization python-3.x
11 questions
4
votes
1
answer
117
views
Calculate optimal game upgrades, v2
This is the second iteration of the code I originally posted here: Calculate optimal game upgrades. Based on the feedback there, I chose to change the code to use a dynamic programming approach with ...
7
votes
2
answers
1k
views
Convert 64-bit Gray code to integer
This algorithm encodes a 64 bit integer.
As input I have a 64 bit integer a, for example:
(a is a single 64 bit number,which I split in 8 bytes for readability) <...
2
votes
1
answer
145
views
Python 3 weighted random choice function memoized version
I have written a function that randomly picks one element from a set with different probabilities for each element, anyway it takes a dictionary as argument, the keys of the dictionary are the choices ...
1
vote
1
answer
494
views
Optimizing solution of Sum of Pairs: Codewars in Python
I need help to optimize my code for huge lists with approx. 10000000 elements. Is there a way to improve my algorithm or should I try to build a new one using a completely different approach?
Task: ...
6
votes
1
answer
437
views
Memoizing a tree's parent pointers in Python
I have a simple binary tree that has no parent pointers.
...
7
votes
2
answers
749
views
Project Euler 357 prime number generator in Python 3
I'm brute forcing the Project Euler 357 since no better algorithm comes to my mind. The challenge asks:
Find the sum of all positive integers n not exceeding 108 such that for every divisor d of n, ...
2
votes
2
answers
738
views
Memoizing decorator with retries - now with backoff added! (Part 3)
A continuation of Memoizing decorator with retries, part 2, and related to https://codereview.stackexchange.com/a/133493/47529. I liked my decorator before, but especially in my original use case of a ...
6
votes
3
answers
587
views
Memoizing decorator with retries, part 2
A while ago I asked this question Memoizing decorator that can retry and then promptly forgot about it. I more recently saw Python decorator for retrying w/exponential backoff and wanted to add ...
12
votes
2
answers
2k
views
Memoizing decorator that can retry
I have some tasks that I'd like to memoize because they connect to a rather slow network and have to wait for the data. Unfortunately this network can be a little finnicky and we get occasional ...
5
votes
2
answers
368
views
Comparison of Fibonacci (Multinacci) Functions in Python3
After coming up with a formula on this Stack Overflow question, defeating recursion limits and finding a few new ways of calculating these numbers (as per this Stack Overflow question), I decided that ...
2
votes
2
answers
1k
views
Python memoization decorator
I have spent all night whipping up this recipe. It's my first Python decorator. I feel like I have a full understanding of how decorators work now and I think I came up with a good object-oriented ...