* Fix insertion fail in ["*X", "*XX"] cases
Consider a word, and a copy of that word, but with the last letter repeating twice. (e.g., ["ABC", "ABCC"])
When adding the second word's last letter, it only compares the previous word's prefix—the last letter of the word already in the Radix Tree: 'C'—and the letter to be added—the last letter of the word we're currently adding: 'C'. So it wrongly passes the "Case 1" check, marks the current node as a leaf node when it already was, then returns when there's still one more letter to add.
The issue arises because `prefix` includes the letter of the node itself. (e.g., `nodes: {'C' : RadixNode()}, is_leaf: True, prefix: 'C'`) It can be easily fixed by simply adding the `is_leaf` check, asking if there are more letters to be added.
- Test Case: `"A AA AAA AAAA"`
- Fixed correct output:
```
Words: ['A', 'AA', 'AAA', 'AAAA']
Tree:
- A (leaf)
-- A (leaf)
--- A (leaf)
---- A (leaf)
```
- Current incorrect output:
```
Words: ['A', 'AA', 'AAA', 'AAAA']
Tree:
- A (leaf)
-- AA (leaf)
--- A (leaf)
```
*N.B.* This passed test cases for [Croatian Open Competition in Informatics 2012/2013 Contest #3 Task 5 HERKABE](https://hsin.hr/coci/archive/2012_2013/)
* Add a doctest for previous fix
* improve doctest readability
* Add note in CONTRIBUTING.md about not asking to be assigned to issues
Add a paragraph to CONTRIBUTING.md explicitly asking contributors to not ask to be assigned to issues
* Update CONTRIBUTING.md
* Update CONTRIBUTING.md
---------
Co-authored-by: Christian Clauss <cclauss@me.com>
* chore: Fix failing tests (ignore S307 "possibly insecure function")
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* fix: Move noqa back to right line
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Add powersum problem
* Add doctest
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Add more doctests
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Add more doctests
* Improve paramater name
* Fix line too long
* Remove global variables
* Apply suggestions from code review
* Apply suggestions from code review
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
* updating DIRECTORY.md
* Clarify wording in PR template
* Clarify CONTRIBUTING.md wording about adding issue numbers
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Add suggested change from review to CONTRIBUTING.md
Co-authored-by: Christian Clauss <cclauss@me.com>
* Incorporate review edit to CONTRIBUTING.md
Co-authored-by: Christian Clauss <cclauss@me.com>
---------
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
* Added minimum waiting time problem solution using greedy algorithm
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* ruff --fix
* Add type hints
* Added two more doc test
* Removed unnecessary comments
* updated type hints
* Updated the code as per the code review
* Added recursive algo to calculate product sum from an array
* Added recursive algo to calculate product sum from an array
* Update doc string
* Added doctest for product_sum function
* Updated the code and added more doctests
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Added more test coverage for product_sum method
* Update product_sum.py
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update .pre-commit-config.yaml
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Added apr_interest function to financial
* Update interest.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update financial/interest.py
* float
---------
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* fix issue #8715
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* updating DIRECTORY.md
* feat: Count negative numbers in sorted matrix
* updating DIRECTORY.md
* chore: Fix pre-commit
* refactor: Combine functions into iteration
* style: Reformat reference
* feat: Add timings of each implementation
* chore: Fix problems with algorithms-keeper bot
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* test: Remove doctest from benchmark function
* Update matrix/count_negative_numbers_in_sorted_matrix.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update matrix/count_negative_numbers_in_sorted_matrix.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update matrix/count_negative_numbers_in_sorted_matrix.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update matrix/count_negative_numbers_in_sorted_matrix.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update matrix/count_negative_numbers_in_sorted_matrix.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update matrix/count_negative_numbers_in_sorted_matrix.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* refactor: Use sum instead of large iteration
* refactor: Use len not sum
* Update count_negative_numbers_in_sorted_matrix.py
---------
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
* refactored the code
* the code will now pass the test
* looked more into it and fixed the logic
* made the code easier to read, added comments and fixed the logic
* got rid of redundant code + plaintext can contain chars that are not in the alphabet
* fixed the reduntant conversion of ascii_uppercase to a list
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* keyword and plaintext won't have default values
* ran the ruff command
* Update linear_discriminant_analysis.py and rsa_cipher.py (#8680)
* Update rsa_cipher.py by replacing %s with {}
* Update rsa_cipher.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update linear_discriminant_analysis.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update linear_discriminant_analysis.py
* Update linear_discriminant_analysis.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update linear_discriminant_analysis.py
* Update linear_discriminant_analysis.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update linear_discriminant_analysis.py
* Update machine_learning/linear_discriminant_analysis.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update linear_discriminant_analysis.py
* updated
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
* fixed some difficulties
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* added comments, made printing mapping optional, added 1 test
* shortened the line that was too long
* Update ciphers/mixed_keyword_cypher.py
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Rohan Anand <96521078+rohan472000@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
* Improved Graph Implementations
Provides new implementation for graph_list.py and graph_matrix.py along with pytest suites for each. Fixes#8709
* Graph implementation style fixes, corrections, and refactored tests
* Helpful docs about graph implementation
* Refactored code to separate files and applied enumerate()
* Renamed files and refactored code to fail fast
* Error handling style fix
* Fixed f-string code quality issue
* Last f-string fix
* Added return types to test functions and more style fixes
* Added more function return types
* Added more function return types pt2
* Fixed error messages
* Added rank of matrix in linear algebra
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Corrected name of function
* Corrected Rank_of_Matrix.py
* Completed rank_of_matrix.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* delete to rename Rank_of_Matrix.py
* created rank_of_matrix
* added more doctests in rank_of_matrix.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* fixed some issues in rank_of_matrix.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* added moreeee doctestsss in rank_of_mtrix.py and fixed some bugss
* Update linear_algebra/src/rank_of_matrix.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update linear_algebra/src/rank_of_matrix.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update linear_algebra/src/rank_of_matrix.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update rank_of_matrix.py
* Update linear_algebra/src/rank_of_matrix.py
Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>