functions: tests and solutions

tests

Here is the code in tests/test_functions.py


solutions

Here are the solutions in functions.py