From 25a98cea2e59f7df14853c6b6854b57363f527c1 Mon Sep 17 00:00:00 2001 From: rpdedeus Date: Mon, 20 Apr 2020 10:02:45 -0400 Subject: [PATCH] Add binary search. --- .gitignore | 7 +++++++ README.md | 9 ++++++++- search.py | 9 +++++++++ test_search.py | 12 ++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 search.py create mode 100644 test_search.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ad7c5ab --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.DS_Store +.idea/ +*.iml +.vscode +__pycache__ +*pyc +*.ipynb_checkpoints \ No newline at end of file diff --git a/README.md b/README.md index b247ebf..c12717d 100644 --- a/README.md +++ b/README.md @@ -1 +1,8 @@ -# PythonFundamentals.Exercises.Algos \ No newline at end of file +# PythonFundamentals.Exercises.Algos + +## Binary Search + +1. Open module search.py. +2. Fill in the function "binary_search". +3. Make sure to include unit tests in test_search.py. + diff --git a/search.py b/search.py new file mode 100644 index 0000000..c8a72f4 --- /dev/null +++ b/search.py @@ -0,0 +1,9 @@ +from typing import List, Optional +import logging + + +def binary_search(list_in: List[int], item: int) -> Optional[int]: + """ + If item exists in list_in, this function returns its position in the list. + """ + pass diff --git a/test_search.py b/test_search.py new file mode 100644 index 0000000..0b53ddd --- /dev/null +++ b/test_search.py @@ -0,0 +1,12 @@ +import unittest +import search +import logging + +logging.basicConfig(level=logging.INFO) + + +class SearchTest(unittest.TestCase): + + def test_binary_search(self): + pass +