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
python
level, 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
tests
create 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
self
within your class methods
- Remember, you'll have access to
- Tests
- You will have folder named
tests
and 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
python
level, 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
tests
folder 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 -
ptw
orpytest-watch