The repository contains 5 solved algorithms. Each algorithm implementation is in a separate folder along with the corresponding unit tests.
- Python 3.10
Description:
Print out the n-th entry in the fibonacci series. The fibonacci series is an ordering of numbers where each number is the sum of the preceeding two. For example, the sequence [0, 1, 1, 2, 3, 5, 8, 13, 21, 34] forms the first ten entries of the fibonacci series.
Example/Usage:
fib(4) # returns 3
Description:
Write a function that accepts an integer N and returns a NxN spiral matrix.
Example/Usage:
matrix(2)
# returns
# [[1, 2],
# [4, 3]]
matrix(3)
# returns
# [1, 2, 3],
# [8, 9, 4],
# [7, 6, 5]]
matrix(4)
# returns
# [[1, 2, 3, 4],
# [12, 13, 14, 5],
# [11, 16, 15, 6],
# [10, 9, 8, 7]]
Description:
Create a queue data structure. The queue should be a class with methods 'add' and 'remove'. Adding to the queue should store an element until it is removed.
Example/Usage:
q = Queue()
q.add(1)
q.remove() # returns 1
Description:
Create a stack data structure. The stack should be a class with methods 'push', 'pop', and 'peek'. Adding an element to the stack should store it until it is removed.
Example/Usage:
s = Stack()
s.push(1)
s.push(2)
s.pop() # returns 2
s.pop() # returns 1
Description:
Write a function that returns the number of vowels used in a string. Vowels are the characters 'a', 'e' 'i', 'o', and 'u'.
Example/Usage:
vowels('Why do you ask?') # returns 4
Description:
Each algorithm has dedicated unit tests collected in test.py
file.
Example/Usage:
unittest.main() # runs all tests