You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
704 B

  1. Algorithm test
  2. ===
  3. Nathan's version of BM search.
  4. Given the skeleton in place in the code, and its type annotations, fill in a simplified version of the BM search algorithm.
  5. It only returns the first occurrence of the pattern, and it only uses the "bad character" criteria from the algorithm.
  6. The lookup table is a sparse dictionary instead of a full alphabet like the C version.
  7. ### Usage
  8. ```bash
  9. $ python3 -m pip install pipenv
  10. # Use virtualenv
  11. $ PIPENV_VENV_IN_PROJECT=true pipenv shell
  12. $ pipenv install --dev
  13. ```
  14. - Unittest
  15. ```bash
  16. $ pipenv run unittest
  17. ```
  18. ### References
  19. - [Boyer-Moore string-search algorithm](https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string-search_algorithm)