Christian Clauss
4b79d771cd
Add more ruff rules ( #8767 )
...
* Add more ruff rules
* Add more ruff rules
* pre-commit: Update ruff v0.0.269 -> v0.0.270
* Apply suggestions from code review
* Fix doctest
* Fix doctest (ignore whitespace)
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-05-26 09:34:17 +02:00
amirsoroush
e4d90e2d5b
change space complexity of linked list's __len__ from O(n) to O(1) ( #8183 )
2023-04-01 08:26:43 +02:00
Christian Clauss
64543faa98
Make some ruff fixes ( #8154 )
...
* Make some ruff fixes
* Undo manual fix
* Undo manual fix
* Updates from ruff=0.0.251
2023-03-01 17:23:33 +01:00
Caeden Perelli-Harris
9bba42eca8
refactor: Indent ... for visual purposes ( #7744 )
2022-10-27 19:42:30 +02:00
Caeden
4d0c830d2c
Add flake8 pluin flake8 bugbear to pre-commit ( #7132 )
...
* ci(pre-commit): Add ``flake8-builtins`` additional dependency to ``pre-commit`` (#7104 )
* refactor: Fix ``flake8-builtins`` (#7104 )
* fix(lru_cache): Fix naming conventions in docstrings (#7104 )
* ci(pre-commit): Order additional dependencies alphabetically (#7104 )
* fix(lfu_cache): Correct function name in docstring (#7104 )
* Update strings/snake_case_to_camel_pascal_case.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update data_structures/stacks/next_greater_element.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update digital_image_processing/index_calculation.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update graphs/prim.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update hashes/djb2.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* refactor: Rename `_builtin` to `builtin_` ( #7104 )
* fix: Rename all instances (#7104 )
* refactor: Update variable names (#7104 )
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* ci: Create ``tox.ini`` and ignore ``A003`` (#7123 )
* revert: Remove function name changes (#7104 )
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Rename tox.ini to .flake8
* Update data_structures/heap/heap.py
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
* refactor: Rename `next_` to `next_item` (#7104 )
* ci(pre-commit): Add `flake8` plugin `flake8-bugbear` (#7127 )
* refactor: Follow `flake8-bugbear` plugin (#7127 )
* fix: Correct `knapsack` code (#7127 )
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
2022-10-13 18:03:06 +02:00
Caeden
d5a9f649b8
Add flake8-builtins to pre-commit and fix errors ( #7105 )
...
Ignore `A003`
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
2022-10-13 19:53:59 +05:30
Sherman Hui
9153db2d27
[mypy] fix: fix mypy error in singly_linked_list.py ( #5517 )
...
The list comprehension shortcut was implicitly expecting a return
value causing a mypy error since `insert_tail` doesn't return a value
2021-10-22 11:39:18 +08:00
Immiel
2e2e1b656c
singly_linked_list: Added additional documentation, type hints and test cases ( #4988 )
...
This is a followup to https://github.com/TheAlgorithms/Python/pull/4973#issuecomment-933117382
As per given suggestion, I've added type hints to certain methods that don't have them. I have also added documentation and example doctests as a usage example for (most of) those that don't have them.
I have also added another test case following the previous test case's format. I noticed that the existing test case from previous pull request might be redundant with the ones I've made, so I decided to create a specific situation where the linked list would have to keep different kinds of data types for each node, in `test_singly_linked_list_2` test function.
Some minor changes in strings has been done to keep things consistent with other parts of the document. If it is undesirable, please let me know.
2021-10-20 16:08:39 +08:00
Du Yuanchao
b81fcef66b
Fixed linked list bug ( #2481 )
...
* * fixed __getitem__() function
* add test
* * updated doctests
* updated __setitem__() func
* fixup! Format Python code with psf/black push
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-09-25 18:08:57 +02:00
Du Yuanchao
18f1dcd48a
Updated singly_linked_list ( #2477 )
...
* Updated singly_linked_list
* fixup! Format Python code with psf/black push
* undo __repr__
* updating DIRECTORY.md
* UNTESTED CHANGES: Add an .__iter__() method.
This will break tests, etc.
* fixup! Format Python code with psf/black push
* len(tuple(iter(self)))
* fixed __repr__()
* Update data_structures/linked_list/singly_linked_list.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update data_structures/linked_list/singly_linked_list.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update data_structures/linked_list/singly_linked_list.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update data_structures/linked_list/singly_linked_list.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update data_structures/linked_list/singly_linked_list.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update data_structures/linked_list/singly_linked_list.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update data_structures/linked_list/singly_linked_list.py
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-09-25 16:09:29 +02:00
Christian Clauss
0e6e5056b3
singly_linked_list.py: psf/black ( #2008 )
...
* singly_linked_list.py: psf/black
* updating DIRECTORY.md
* Update singly_linked_list.py
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-19 13:54:25 +02:00
Christian Clauss
1c62bd10c1
Precision must be a nonnegative integer ( #2013 )
...
* Precision must be a nonnegative integer
* fixup! Format Python code with psf/black push
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-19 15:46:20 +05:30
Akash
f9e0dd94d6
added __len__ function ( #1812 )
...
* added __len__ function
Added a function to count number of nodes in linked list
* Updated __len__ method
used snake_case instead of camel case
* Add tests to __len__()
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-18 18:10:55 +02:00
Christian Clauss
bfcb95b297
Create codespell.yml ( #1698 )
...
* fixup! Format Python code with psf/black push
* Create codespell.yml
* fixup! Format Python code with psf/black push
2020-01-18 13:24:33 +01:00
Logan Lieou
d09a805804
Typo? ( #1653 )
...
* Typo?
newNod -> newNode
* newNode -> new_node
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-01-14 10:21:02 +01:00
Vikas Kumar
0d3c9d586c
Update singly_linked_list.py ( #1593 )
...
* Update singly_linked_list.py
printing current.data rather than node address in __repr__ for a more readable print statement
* eval(repr(c)) == c
The output of `__repr__()` _should look like a valid Python expression that could be used to recreate an object with the same value_.
https://docs.python.org/3.4/reference/datamodel.html#object.__repr__
* += --> +
2019-11-26 06:45:28 +01:00
Hanif Ali
4c37eb7d07
Improved on Singly Linked List Programs ( #1558 )
...
* Improved Singly Linked List
Added String Representations of Nodes and Linked Lists
Added support for indexing and changing of Node data using indices.
* Added a few comments to Linked Lists
* Reformatted to conform to PEP8
* Added from_sequence.py
Convert a Python List to Linked List comprising of Nodes and return head.
* Added print_reverse.py
Recursive program to print the elements of a Linked List in reverse.
* Change 'is not None' for more Pythonicness
2019-11-10 09:47:04 +01:00
Manu M Bhat
cd10c944d1
Issue #1397 ( #1403 )
2019-10-19 20:14:37 +02:00
William Zhang
9eac17a408
psf/black code formatting ( #1277 )
2019-10-05 10:14:13 +05:00
Christian Clauss
47a9ea2b0b
Simplify code by dropping support for legacy Python ( #1143 )
...
* Simplify code by dropping support for legacy Python
* sort() --> sorted()
2019-08-19 15:37:49 +02:00
rohan11074
137871bfef
feature to add input ( #749 )
2019-04-07 23:55:32 +08:00
Ashwek Swamy
f89d3a9ec3
Update singly_linked_list.py
2018-11-01 21:25:45 +05:30
Ashwek Swamy
48aa4c4a01
Update singly_linked_list.py
2018-11-01 21:04:05 +05:30
Alex Brown
91fccecb56
snake_case all the things
2018-10-19 17:14:25 -05:00