Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,25 @@

*Note: this module project repository is for Module 3 (A First-Pass Solution) and Module 4 (Writing Better Solutions) of the Algorithms Sprint.*

## Objectives
## Objectives for A First-Pass Solution

* effectively ask for help by giving the expected vs. experienced behavior, explaining what specific actions they've taken so far, and providing all relevant information and code
* interpret a problem, specification, or diagram and construct a plan for implementing a solution in code
* implement a first-pass solution after selecting from a naïve, brute-force, or greedy approach
* evaluate a first-pass solution and reflect on its validity to decide if the solution needs revision
* apply techniques such as memoization or heuristics to improve an existing first-pass solution
* Effectively ask for help by giving the expected vs. experienced behavior, explaining what specific actions they've taken so far, and providing all relevant information and code
* Interpret a problem, specification, or diagram and construct a plan for implementing a solution in code
* Implement a first-pass solution after selecting from a naïve, brute-force, or greedy approach

## Objectives for Writing Better Solutions

* Evaluate a first-pass solution and reflect on its validity to decide if the solution needs revision
* Apply techniques such as memoization or heuristics to improve an existing first-pass solution

## Introduction

This module project requires you to practice each of the learning objectives by synthesizing them to solve the included challenges. For Module 3, you will complete a first-pass solution for each of the problems. Then, in Module 4, you will improve your previous solution by applying the techniques you learned during pre-instruction and the Guided Project.

These types of algorithmic challenges simulate many of the problems that you might receive during a job interview. They require you to practice using all of your data structures knowledge, problem-solving capabilities, and algorithmic practice that you've done thus far. The more practice you get at applying these skills, the more likely you are to do well under pressure in a job interview setting. Additionally, this practice deepens your understanding through application.

## Instructions and/or completion requirements
## Instructions and/or Completion Requirements
### A First-Pass Solution

Each directory contains a separate problem that you must solve. Inside each directory, you'll find instructions for that problem, a test file, and an empty skeleton file.

Expand All @@ -34,11 +38,14 @@ There isn't an official prescribed order for tackling the problems, though a sub

For each problem, `cd` into the directory, read the instructions for the challenge, implement your solution in the skeleton file, then test it using the provided test file.

The later problems get progressively more difficult, especially when
it comes to deriving a more performant solution. Don't feel bad if you aren't able to figure them out within the project's timeframe. Again, always remember that so long as you put in an earnest effort into attempting to solve these problems, you're learning and getting better. Getting the 'right answer' is just the proverbial cherry on top of the sundae.
The later problems get progressively more difficult, especially when it comes to deriving a more performant solution. Don't feel bad if you aren't able to figure them out within the project's timeframe. Again, always remember that so long as you put in an earnest effort into attempting to solve these problems, you're learning and getting better. Getting the 'right answer' is just the proverbial cherry on top of the sundae.

*Note: Remember, you need to get a first-pass solution for each of the problems for the Module 3 Project. For the Module 4 Project, you will work on improving those solutions and optimizing them for performance.*

### Writing Better Solutions

For the Module 4 project, your main objective is to work on improving at least two of your first-pass solutions from Module 3. In particular, for one of your first-pass solutions, assess the runtime and space complexity of the implementation, think about why it's inefficient and how it could be improved, then implement the improved solution.

## Resources

When you confront a problem you haven't encountered before, the general strategy (adapted from [George Pólya's Problem Solving Principles](https://en.wikipedia.org/wiki/How_to_Solve_It)) is as follows:
Expand Down
17 changes: 15 additions & 2 deletions eating_cookies/eating_cookies.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,25 @@
Returns: an integer
'''
def eating_cookies(n):
# Your code here


if n == 0:
return 1
# because there only one way to eat one cookie
if n < 0:
return 0
# because there no way to eat no cookies
if n >= 1:
return eating_cookies(n-3)+eating_cookies(n-2)+eating_cookies(n-1)
# Applys the recurrsion part of problem, since we want a permutations

pass

if __name__ == "__main__":
# Use the main function here to test out your implementation
num_cookies = 5
cookies = 3

print(f"There are {eating_cookies(num_cookies)} ways for Cookie Monster to each {num_cookies} cookies")


print(f"There are {eating_cookies(cookies)} ways for Cookie Monster to each {cookies} cookies")
5 changes: 3 additions & 2 deletions knapsack/knapsack.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

def knapsack_solver(items, capacity):
# Your code here

if items == 0 or capacity == 0
pass


Expand All @@ -25,4 +25,5 @@ def knapsack_solver(items, capacity):
file_contents.close()
print(knapsack_solver(items, capacity))
else:
print('Usage: knapsack.py [filename] [capacity]')
print('Usage: knapsack.py [filename] [capacity]')
#
Loading