401 data structures and algorithms code challenges
Python
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.
python
level, with the name of the data structure and complete your implementation there
linked_list
linked_list/linked_list.py
Follow Python naming conventions
class LinkedList:
def __init__(self):
# ... initialization code
def method_name(self):
# method body
tests
create a test file called test_[data_structure].py
tests/test_linked_list.py
from linked_list.linked_list import LinkedList
self
within your class methodstests
and within it, a test file called test_[data_structure].py
tests/test_linked_list.py
Code challenges should be completed within a folder named code_challenges
under the python
level
python
level, with the name of the code challenge
snake_cased
code_challenges/find_maximum_value
snake_case
find_maximum_value.py
from linked_list.linked_list import LinkedList
find_maximum_value(linked_list)
tests
folder at the root of project.
test_[challenge].py
tests/find_maximum_value.py
from code_challenges.find_maximum_value import find_maximum_value
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:
pytest
pytest -k some_filter_text
ptw
or pytest-watch