Code I wrote to solve the quizzes when taking the course Algorithms I at Coursera.
Some code load input tests from text files. Please, be advised to change the location to resamble your configuration.
The path in those files always point to /home/ubuntu/coursera
Find the code inside the src folder:
- Stair Problem :
- Definition: A child is running up a staircase with n steps and can hop either 1 step, 2 steps, or 3 steps at a time. Implement a method to count how many possible ways the child can run up the stairs.
- There are three commented solutions in the code:
- Using dynamic programming
- Counting (my implementation)
- An attempt to use matrix power linear algebra, which would lead to a O(1) solution. This attempt is partially wrong. I should have used the matrix of eigenvectors, but instead I factorized using SVD. Will fix soon.
In the folder others you can find other trick algorithms with discussion and explanation.