- Code Challenge 1: Array Reverse
- Code Challenge 2: Array Insert Shift
- Code Challenge 3: Array Binary Search
- Code Challenge 4: Mock Inyerview Matrix
- Code Challenge 5: Linked List
- Code Challenge 6: Linked List insertions
- Code Challenge 7: Linked List Kth
- Code Challenge 8: Linked List Zip
- Code Challenge 9: Stack and Queue
- Code Challenge 11: Stack and Queue Pseudo
- Code Challenge 12: Stack and Queue Animal Shelter
- Code Challenge 13: Stack and Queue Brackets
- Code Challenge 14: Mock Interview: Max Stack
- Code Challenge 15: Trees: Binary Tree and Binary Search Tree
- Code Challenge 16: Trees: Tree Max
- Code Challenge 17: Trees: Tree Breadth First
- Code Challenge 18: Trees: K-ary Fizz Buzz
- Code Challenge 29: Mock Interview Linked List Reverse
- Code Challenge 30: Hashtable
- Code Challenge 31: Hashtable Repeated Word
- Code Challenge 32: Tree Intersection
- Code Challenge 33: Hashtable Left Join
- Code Challenge 34: Hashtable Most Common Word
- Code Challenge 35: Graph
- Code Challenge/Lab 35: Mock Interview Linked List Remove Dups
- Code Challenge 36: Binary Tree Sum
Each type of code challenge has slightly different instructions. Please refer to the notes and examples below for instructions for each DS&A assignment type.
-
Create a new folder under the
pythonlevel, with the name of the data structure and complete your implementation there- i.e.
linked_list
- i.e.
-
Implementation (the data structure "class")
-
The implementation of the data structure should match package name
- i.e.
linked_list/linked_list.py
- i.e.
-
Follow Python naming conventions
class LinkedList: def __init__(self): # ... initialization code def method_name(self): # method body
-
-
Tests
- Within folder
testscreate a test file calledtest_[data_structure].py- i.e.
tests/test_linked_list.py - Your tests will then need to require the data structure you're testing
- i.e.
from linked_list.linked_list import LinkedList
- i.e.
- i.e.
- Within folder
- Work within the existing data structure implementation
- Create a new method within the class that solves the code challenge
- Remember, you'll have access to
selfwithin your class methods
- Remember, you'll have access to
- Tests
- You will have folder named
testsand within it, a test file calledtest_[data_structure].py- i.e.
tests/test_linked_list.py - Add to the tests written for this data structure to cover your new method(s)
- i.e.
- You will have folder named
Code challenges should be completed within a folder named code_challenges under the python level
- Daily Setup:
- Create a new folder under the
pythonlevel, with the name of the code challenge- Each code challenge assignment identifies the branch name to use, for example 'find-maximum-value'
- For clarity, create your folder with the same name, ensuring that it's
snake_cased - i.e. For a challenge named 'find_maximum_value', create the folder:
code_challenges/find_maximum_value
- Code Challenge Implementation
- Each code challenge requires a function be written, for example "find maximum value"
- Name the actual challenge file with the name of the challenge, in
snake_case- i.e.
find_maximum_value.py
- i.e.
- Reminder: Your challenge file will then need to require the data structure you're using to implement
- i.e.
from linked_list.linked_list import LinkedList
- i.e.
- Your challenge function name is up to you, but name something sensible that communicates the function's purpose. Obvious is better than clever
- i.e.
find_maximum_value(linked_list)
- i.e.
- Tests
- Ensure there is a
testsfolder at the root of project.- i.e. a sibling of this document.
- within it, a test file called
test_[challenge].py- i.e.
tests/find_maximum_value.py - Your test file would require the challenge file found in the directory above, which has your exported function
- i.e.
from code_challenges.find_maximum_value import find_maximum_value
- i.e.
- i.e.
- Ensure there is a
- Create a new folder under the
If you setup your folders according to the above guidelines, running tests becomes a matter of deciding which tests you want to execute. Jest does a good job at finding the test files that match what you specify in the test command
From the root of the data-structures-and-algorithms/python folder, execute the following commands:
- Run every possible test -
pytest - Run filtered tests -
pytest -k some_filter_text - Run in watch mode -
ptworpytest-watch