All Questions
Tagged with python-2.x dynamic-programming
12 questions
6
votes
1
answer
990
views
Printing bowTie pattern in efficient and pythonic way
I've posted code/library to GitHub for first time over here.
The code is pretty simple. It generates a BowTie pattern of given size and characters.
I did attempt to implement DP by calculating only ...
7
votes
1
answer
298
views
Dynamic Programming with Project Euler problem 67
I am a beginner with python and programming in general. I started teaching myself about 2 months ago.
I've been working my way through Project Euler and a few similar sites to build my chops, and ...
7
votes
2
answers
702
views
Recursive function and memorization to find minimum operations to transform n to 1
I'm a new, self-taught programmer working on the Google FooBar challenge. I've submitted my answer (code at bottom) and it was accepted, but I'd like suggestions on how to improve my solution.
...
4
votes
1
answer
2k
views
Student Attendance Record II
I'm currently working on the Student Attendance Record II problem:
Given a positive integer \$n\$, return the number of all possible
attendance records with length \$n\$, which will be regarded ...
3
votes
1
answer
248
views
Dynamic programming solution for cross river algorithm (part 2)
I'm working on the cross river problem (previous post here). Any advice on performance improvement in terms of algorithm time complexity, code bugs or code style advice is appreciated.
More ...
5
votes
1
answer
1k
views
Dynamic programming solution for cross river algorithm
Working on below cross river problem, and post my code in Python 2.7 using dynamic programming. Any advice on performance improvement in terms of algorithm time complexity, code bugs or code style ...
4
votes
1
answer
1k
views
Guess number with lower or higher hints
Problem statement
Two players - Alice and Bob. Alice needs to guess a number \$n\$, from
range \$[1, N]\$, \$N \le 200\$
In \$i\$th turn, Alice guesses a number \$i\$
Bob chooses to ...
4
votes
1
answer
432
views
Different path for grid move
Given a m * n grids, and one is allowed to move up or right, find the different number of paths between two grid points.
My major idea is, if move r steps right, <...
5
votes
2
answers
1k
views
High execution time of LCS length program in Python2
I was trying to solve the Longest Common Subsequence problem on a HackerRank exercise.
It's quite simple and straightforward, just print out the length of the LCS. I submitted this code:
...
2
votes
2
answers
107
views
Find the best path amongst N random points
For an application with a graphical canvas, I want to generate N points. But then I want to link those points, and I want to find the best path through those points.
I wanted to use a dynamic ...
2
votes
1
answer
98
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 ...
4
votes
4
answers
12k
views
Find the minimum number of coins
I'm trying to learn dynamic programming and the most popular one is to find the minimum number of coins for the change. I come up with this but I just want to improve this code which I think it could ...