* rsa key doctest
* move doctest to module docstring
* all tests to doctest
* moved is_right to property
* is right test
* fixed rsa doctest import
* Test error when deleting non-existing element
* fixing ruff EM102
* convert property 'is_right' to one-liner
Also use 'is' instead of '=='
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
* child instead of children
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
* remove type hint
* Update data_structures/binary_tree/binary_search_tree.py
---------
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
* Fix ruff errors
Renamed neural_network/input_data.py to neural_network/input_data.py_tf
because it should be left out of the directory for the following
reasons:
1. Its sole purpose is to be used by neural_network/gan.py_tf, which is
itself left out of the directory because of issues with TensorFlow.
2. It was taken directly from TensorFlow's codebase and is actually
already deprecated. If/when neural_network/gan.py_tf is eventually
re-added back to the directory, its implementation should be changed
to not use neural_network/input_data.py anyway.
* updating DIRECTORY.md
* Change input_data.py_tf file extension
Change input_data.py_tf file extension because algorithms-keeper bot is being picky about it
---------
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* enhance the implementation of queue using list
* enhance readability of queue_on_list.py
* rename 'queue_on_list' to 'queue_by_list' to match the class name
* 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
* 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>
* 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>
* Solving the `Top k most frequent words` problem using a max-heap
* Mentioning Python standard library solution in `Top k most frequent words` docstring
* ruff --fix .
* updating DIRECTORY.md
---------
Co-authored-by: Amos Paribocci <aparibocci@gmail.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* Bloom filter with tests
* has functions constant
* fix type
* isort
* passing ruff
* type hints
* type hints
* from fail to erro
* captital leter
* type hints requested by boot
* descriptive name for m
* more descriptibe arguments II
* moved movies_test to doctest
* commented doctest
* removed test_probability
* estimated error
* added types
* again hash_
* Update data_structures/hashing/bloom_filter.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* from b to bloom
* Update data_structures/hashing/bloom_filter.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update data_structures/hashing/bloom_filter.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* syntax error in dict comprehension
* from goodfather to godfather
* removed Interestellar
* forgot the last Godfather
* Revert "removed Interestellar"
This reverts commit 35fa5f5c4b.
* pretty dict
* Apply suggestions from code review
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update bloom_filter.py
---------
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Queue implementation using two Stacks
* fix typo in queue/queue_on_two_stacks.py
* add 'iterable' to queue_on_two_stacks initializer
* make queue_on_two_stacks.py generic class
* fix ruff-UP007 in queue_on_two_stacks.py
* enhance readability in queue_on_two_stacks.py
* Create queue_by_two_stacks.py
---------
Co-authored-by: Christian Clauss <cclauss@me.com>
* pre-commit: Upgrade psf/black for stable style 2023
Updating https://github.com/psf/black ... updating 22.12.0 -> 23.1.0 for their `2023 stable style`.
* https://github.com/psf/black/blob/main/CHANGES.md#2310
> This is the first [psf/black] release of 2023, and following our stability policy, it comes with a number of improvements to our stable style…
Also, add https://github.com/tox-dev/pyproject-fmt and https://github.com/abravalheri/validate-pyproject to pre-commit.
I only modified `.pre-commit-config.yaml` and all other files were modified by pre-commit.ci and psf/black.
* [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>
* add prefix sum
* updating DIRECTORY.md
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
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>
* added radix tree to data structures
* added doctests
* solved flake8
* added type hints
* added description for delete function
* Update data_structures/trie/radix_tree.py
* Update radix_tree.py
* Update radix_tree.py
* Update radix_tree.py
Co-authored-by: Alex de la Cruz <alex@Alexs-MacBook-Air.local>
Co-authored-by: Christian Clauss <cclauss@me.com>
* Description of DOuble hasing
* Fix sheebang
* Update double_hash.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update double_hash.py
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Add files via upload
* Delete permutations.cpython-310.pyc
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update permutations.py
* Update permutations.py
* Add files via upload
* Delete permutations.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update permutations.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update permutations.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update permutations.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update data_structures/arrays/permutations.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update permutations.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update permutations.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update data_structures/arrays/permutations.py
Co-authored-by: Chris O <46587501+ChrisO345@users.noreply.github.com>
* Update permutations.py
* Update permutations.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update permutations.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>
Co-authored-by: Chris O <46587501+ChrisO345@users.noreply.github.com>
* Adopt Python >= 3.8 assignment expressions using auto-walrus
* updating DIRECTORY.md
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
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>
* feat: Implement binary tree path sum (#7135)
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update data_structures/binary_tree/binary_tree_path_sum.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* refactor: Rename `dfs` to `depth_first_search`
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
* Different views of binary tree added
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* mypy errors resolved
* doc test for remaining functions
* Flake8 comments resolved
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Example moved in if block
* doctest cases added
* Cases from if block removed
* Update data_structures/binary_tree/diff_views_of_binary_tree.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update data_structures/binary_tree/diff_views_of_binary_tree.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* PR Comments resolved
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* flake8 warning resolved
* Changes revered
* flake8 issue resolved
* Put the diagrams just above the doctests
* Update diff_views_of_binary_tree.py
* Update diff_views_of_binary_tree.py
* I love mypy
* [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>
Co-authored-by: Christian Clauss <cclauss@me.com>
* feat: Binary tree node sum (#7020)
* feat: Sum of all nodes in binary tree explanation (#7020)
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update data_structures/binary_tree/binary_tree_node_sum.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* refactor: Change replace method with `__iter__` overriding (#7020)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>