* Enable ruff SIM102 rule
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix
* [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>
* Enable ruff PLR5501 rule
* [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 implementing stack using two queues
* Update Stack using two queues
* Update stack_using_two_queues.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update stack_using_two_queues.py
* Update stack_using_two_queues.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update stack_using_two_queues.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update stack_using_two_queues.py
* Update stack_using_two_queues.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 bug and edit doctests
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Add type hints, raiseError and other minor adjustments
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Cleaning code
* [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 doctests, exceptions, type hints and fix bug for infix_to_prefix_conversion.py
Add doctests
Add exceptions for expressions with invalid bracket positions
Add type hints for functions
Fix a bug on line 53 (57 in PR)
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Change type hints in infix_to_prefix_conversion.py
* Remove printing trailing whitespace in the output table
* Fix type hint errors
* Fix doctests
* Adjust table convention in output and doctests
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Add doctests for infix_2_postfix()
* Update print_width
* Update print_width
* Fix the doctests
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
* Updated postfix_evaluation.py to support Unary operators and floating point numbers Fixes#8754 and #8724
Also merged evaluate_postfix_notations.py and postfix_evaluation.py into postfix_evaluation.py
Signed-off-by: Arijit De <arijitde2050@gmail.com>
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Updated postfix_evaluation.py to support Unary operators and floating point numbers. Fixes#8754 and formatted code to pass ruff and black test.
Also merged evaluate_postfix_notations.py and postfix_evaluation.py into postfix_evaluation.py which fixes#8724 and made sure it passes doctest
Signed-off-by: Arijit De <arijitde2050@gmail.com>
* Fixed return type hinting required by pre commit for evaluate function
Signed-off-by: Arijit De <arijitde2050@gmail.com>
* Changed line 186 to return only top of stack instead of calling the get_number function as it was converting float values to int, resulting in data loss. Fixes#8754 and #8724
Signed-off-by: Arijit De <arijitde2050@gmail.com>
* Made the requested changes
Also changed the code to make the evaluate function first convert all the numbers and then process the valid expression.
* Fixes#8754, #8724 Updated postfix_evaluation.py
postfix_evaluation.py now supports Unary operators and floating point numbers.
Also merged evaluate_postfix_notations.py and postfix_evaluation.py into postfix_evaluation.py which fixes#8724. Added a doctest example with unary operator.
* Fixes#8754, #8724 Updated postfix_evaluation.py
postfix_evaluation.py now supports Unary operators and floating point numbers.
Also merged evaluate_postfix_notations.py and postfix_evaluation.py into postfix_evaluation.py which fixes#8724. Added a doctest example with unary operator.
* Fixes#8754, #8724 Updated the parse_token function of postfix_evaluation.py
ostfix_evaluation.py now supports Unary operators and floating point numbers.
Also merged evaluate_postfix_notations.py and postfix_evaluation.py into postfix_evaluation.py which fixes#8724. Added a doctest example with unary operator and invalid expression.
* Fixes#8754, #8724 Updated postfix_evaluation.py
postfix_evaluation.py now supports Unary operators and floating point numbers.
Also merged evaluate_postfix_notations.py and postfix_evaluation.py into postfix_evaluation.py which fixes#8724. Added a doctest example with unary operator and invalid expression.
* Update postfix_evaluation.py
* Update postfix_evaluation.py
* Update postfix_evaluation.py
* Update postfix_evaluation.py
* Update postfix_evaluation.py
---------
Signed-off-by: Arijit De <arijitde2050@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>
* 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>
* Fix type annotations for linked_stack.py
* Replace Optional with inline union type
* Rename linked_stack to stack_with_singly_linked_list
* Rename stack_using_dll to stack_with_doubly_linked_list
* updating DIRECTORY.md
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* Updated Pop function
Added underflow condition
* Update Pop Function
Added condition to check underflow of stack
* Update stack.py
* if not self.stack: raise StackUnderflowError
* Add doctests
* StackUnderflowError
* ..., not ....
* Update stack.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Create evaluate_postfix_notations.py
Adding in the evaluate postfix notation using Stacks
one of the common use with simple stack question
creating a new file for the data structure of stacks
* Create evaluate_postfix_notations.py
Adding in the evaluate postfix notation using Stacks
one of the common use with simple stack question
creating a new file for the data structure of stacks
* Delete evaluate_postfix_notations.py
* Evaluate postfix expression stack clean approach
Sending in the PR again as the Previous request failed in pre commit
* Update evaluate_postfix_notations.py
* Update evaluate_postfix_notations.py
Made changes as per the required for fixing the failing pre-commits.
* Update evaluate_postfix_notations.py
Made changes as suggested by @cclauss
* Update evaluate_postfix_notations.py
fixed pre-commit fails
* Update evaluate_postfix_notations.py
fixing pre-commit fails
* Update evaluate_postfix_notations.py
Deleted trailing white spaces causing pre-commits to fail
* Update data_structures/stacks/evaluate_postfix_notations.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update data_structures/stacks/evaluate_postfix_notations.py
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
* created dijkstra's two stack algorithm
* Made changes to dijkstras two stack algorithm for documentation and
testing purposes.
* Made changes to dijkstras two stack algorithm for documentation and
testing purposes.
* Fixed Grammar Mistake
* Added Explanation Reference
* Imported stack instead of using my own
Changed a few minor things.
* Imported stack instead of using my own
Changed a few minor things.
* Update data_structures/stacks/dijkstras_two_stack_algorithm.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update dijkstras_two_stack_algorithm.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Tighten up psf/black and flake8
* Fix some tests
* Fix some E741
* Fix some E741
* updating DIRECTORY.md
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* Fix psf/black issues than fail the build
* fixup! Format Python code with psf/black push
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* With all suggested changes ✅
possibly covered all the recommended guidelines
* Updated with both slow and faster algorithms
possibally covered all the recomendations
* removed the time comparision part!
* Update data_structures/stacks/next_greater_element.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 data_structures/stacks/next_greater_element.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>
* Add benchmark using timeit
https://docs.python.org/3/library/timeit.html
The performance delta between these two implementation is quite small...
```
next_greatest_element_slow(): 1.843442126
next_greatest_element(): 1.828941414
```
* Optimize slow() to create fast() - Three algorithms in the race
Three algorithms in the race
* Use a bigger test array with floats, negatives, zero
* Setup import next_greatest_element_fast
Co-authored-by: Christian Clauss <cclauss@me.com>
* Stack using double linked list
* Test with doctests
* Update stack_using_dll.py
* Update stack_using_dll.py
* Update stack_using_dll.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update DIRECTORY
* Updated DIRECTORY
* Fixed bug in directory build and re-build the directory.md
* fixed url issue
* fixed indentation in Directory.md
* Add problem-18 of project-euler
* Delete sol1.py
* Delete files
* Added more details to question
* Added doctest in printNGE()
* Made changes to fix Travis CI build
* Remove the trailing whitespace