Commit Graph

163 Commits

Author SHA1 Message Date
Reniz Shah
e82e93ac0d add algorithm to check if given string is valid number or not
Add a new file string_is_valid_number.py in string directory
2024-08-07 17:54:23 +05:30
Saurabh Mahapatra
c1dc8e97f7
Create count_vowels.py (#11474)
* Create count_vowels.py

* [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>
2024-07-04 20:16:24 +02:00
pre-commit-ci[bot]
716bdeb68b
[pre-commit.ci] pre-commit autoupdate (#11473)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.4.10 → v0.5.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.4.10...v0.5.0)
- [github.com/pre-commit/mirrors-mypy: v1.10.0 → v1.10.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.10.0...v1.10.1)

* Fix ruff issues

* Fix ruff issues

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2024-07-02 07:02:29 +02:00
Maxim Smolskiy
d016fda51c
Enable ruff RUF003 rule (#11376)
* Enable ruff RUF003 rule

* Update pyproject.toml

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2024-04-22 21:56:14 +02:00
Maxim Smolskiy
4700297b3e
Enable ruff RUF002 rule (#11377)
* Enable ruff RUF002 rule

* Fix

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2024-04-22 21:51:47 +02:00
Maxim Smolskiy
a42eb35702
Enable ruff E741 rule (#11370)
* Enable ruff E741 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>
2024-04-19 21:30:22 +02:00
Maxim Smolskiy
39daaf8248
Enable ruff RUF100 rule (#11337) 2024-04-01 21:36:41 +02:00
Maxim Smolskiy
516a3028d1
Enable ruff PLR5501 rule (#11332)
* 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>
2024-03-28 18:25:41 +01:00
pre-commit-ci[bot]
bc8df6de31
[pre-commit.ci] pre-commit autoupdate (#11322)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.2.2 → v0.3.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.2.2...v0.3.2)
- [github.com/pre-commit/mirrors-mypy: v1.8.0 → v1.9.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.8.0...v1.9.0)

* [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>
2024-03-13 07:52:41 +01:00
Pedram_Mohajer
154e5e8681
Update levenshtein_distance.py (#11171)
* Update levenshtein_distance.py

* Update levenshtein_distance.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update levenshtein_distance.py

* Update levenshtein_distance.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update levenshtein_distance.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update levenshtein_distance.py

* Update levenshtein_distance.py

* [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>
2023-11-26 23:46:54 +01:00
Suyash Dongre
12e401650c
Added doctest to string_switch_case.py (#11136)
* Added doctest to string_switch_case.py

* Update string_switch_case.py
2023-11-06 18:18:41 +06:00
Suyash Dongre
fa508d7b8b
Added doctest to detecting_english_programmatically.py (#11135) 2023-11-06 18:14:39 +06:00
Ed
e3eb9daba4
Add bitap_string_match algo (#11060)
* Add bitap_string_match algo

* Fix types

* Fix spelling and add ignore word

* Add suggested changes and change return type

* Resolve suggestions
2023-10-29 00:48:50 +02:00
Saurabh Mahapatra
ade2837e41
Update capitalize.py (#10573)
* Update capitalize.py

* Update strings/capitalize.py

---------

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2023-10-26 04:25:08 -04:00
Iyiola Aloko
76acc6de60
Adding doctests to frequency_finder.py (#10341)
* Update frequency_finder.py

* Update frequency_finder.py

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-24 21:53:31 +00:00
gio-puter
0601b56173
Add tests without modifying code (#10740)
* Contributes to #9943
Added doctest to largest_of_very_large_numbers.py
Added doctest to word_patterns.py
Added doctest to onepad_cipher.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Contributes to #9943
Added doctest to maths/largest_of_very_large_numbers.py
Added doctest to strings/word_patterns.py
Added doctest to ciphers/onepad_cipher.py

* Add tests without modifying code #10740
Added test to maths/largest_of_very_large_numbers
Added test to strings/word_patterns.py
Added test to ciphers/onepad_cipher.py

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-10-22 07:42:26 +02:00
anshul-2010
33888646af
Edit Distance Algorithm for String Matching (#10571)
* Edit Distance Algorithm for String Matching

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Apply suggestions from code review

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update edit_distance.py

* [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: Tianyi Zheng <tianyizheng02@gmail.com>
2023-10-19 08:38:02 -04:00
Marek Mazij
9de1c49fe1
feat: Polish ID (PESEL) checker added (#10618)
* feat: Polish ID (PESEL) checker added

* refactor: 'sum' variable renamed to 'subtotal'

* style: typos

* Apply suggestions from code review

* [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>
2023-10-17 20:24:16 +02:00
Saurabh Mahapatra
00165a5fb2
Added test cases to join.py (#10629)
* Added test cases to join.py

* [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>
2023-10-17 02:36:12 -04:00
Saurabh Mahapatra
f968dda5e9
Updated Comments on upper.py (#10442)
* Updated Comments on upper.py

* Update upper.py

* Update upper.py

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-14 15:02:37 -04:00
Aakash Giri
3ba2338479
Add Title Case Conversion (#10439)
[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

added more test case and type hint

[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

updated naming convention
2023-10-14 18:17:11 +02:00
Saurabh Mahapatra
1117a50665
Modified comments on lower.py (#10369) 2023-10-13 11:55:32 -04:00
Saahil Mahato
c85506262d
Add Damerau-Levenshtein distance algorithm (#10159)
* Add Damerau-Levenshtein distance algorithm

* fix: precommit check

* fix: doc correction

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* refactor: use variable for length and doc correction

* Update damerau_levenshtein_distance.py

* Update damerau_levenshtein_distance.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>
2023-10-13 15:18:52 +02:00
Christian Clauss
3f094fe49d
Ruff pandas vet (#10281)
* Python linting: Add ruff rules for Pandas-vet and Pytest-style

* updating DIRECTORY.md

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2023-10-11 14:30:02 -04:00
Anshu Sharma
66e4ea6a62
Consolidated two scripts reverse_letters.py and reverse_long_words.py into one (#10140)
* Conolidated two scripts reverse_letters.py and reverse_long_words.py into one because of similar functionality

* Added a new line to accomodate characters without going over 88 char limit

* fixed grammar to pass pre-commit

* Changed faulty test case entirely to pass pre commit

* fixed a test case which was wrong

---------

Co-authored-by: Keyboard-1 <142900182+Keyboard-1@users.noreply.github.com>
2023-10-09 09:17:22 +13:00
Saurabh Mahapatra
e89ae55d8e
Create strip.py (#10011)
* Create strip.py

* Update strip.py
2023-10-08 12:10:41 -04:00
Marek Mazij
7f94a73eec
camelCase to snake_case conversion - Fixes #9726 (#9727)
* First commit

camel case to snake case conversion algorithm, including numbers

* code modified to not use regex
2023-10-06 11:05:23 +13:00
Rohan Sardar
e29024d14a
Program to convert a given string to Pig Latin (#9712)
* Program to convert a given string to Pig Latin 

This is a program to convert a user given string to its respective Pig Latin form

As per wikipedia (link: https://en.wikipedia.org/wiki/Pig_Latin#Rules)
For words that begin with consonant sounds, all letters before the initial vowel are placed at the end of the word sequence. Then, "ay" is added, as in the following examples:
"pig" = "igpay"
"latin" = "atinlay"
"banana" = "ananabay"

When words begin with consonant clusters (multiple consonants that form one sound), the whole sound is added to the end when speaking or writing.
"friends" = "iendsfray"
"smile" = "ilesmay"
"string" = "ingstray"

For words that begin with vowel sounds, one just adds "hay", "way" or "yay" to the end. Examples are:
"eat" = "eatway"
"omelet" = "omeletway"
"are" = "areway"

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update pig_latin.py

Added f-string

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update pig_latin.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update pig_latin.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update pig_latin.py

* Update pig_latin.py

* Update pig_latin.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>
2023-10-05 10:52:40 +02:00
Hetarth Jain
35dd529c85
Returning Index instead of boolean in knuth_morris_pratt (kmp) function, making it compatible with str.find(). (#9083)
* Update knuth_morris_pratt.py - changed Boolean to Index

* Update knuth_morris_pratt.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update knuth_morris_pratt.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update knuth_morris_pratt.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update back_propagation_neural_network.py

* Update back_propagation_neural_network.py

* Update strings/knuth_morris_pratt.py

* Update knuth_morris_pratt.py

* Update knuth_morris_pratt.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>
2023-09-28 20:24:46 +02:00
pre-commit-ci[bot]
421ace81ed
[pre-commit.ci] pre-commit autoupdate (#9013)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.285 → v0.0.286](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.285...v0.0.286)
- [github.com/tox-dev/pyproject-fmt: 0.13.1 → 1.1.0](https://github.com/tox-dev/pyproject-fmt/compare/0.13.1...1.1.0)

* updating DIRECTORY.md

* Fis ruff rules PIE808,PLR1714

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2023-08-29 15:18:10 +02:00
Caeden Perelli-Harris
4b7ecb6a81
Create is valid email address algorithm (#8907)
* feat(strings): Create is valid email address

* updating DIRECTORY.md

* feat(strings): Create is_valid_email_address algorithm

* chore(is_valid_email_address): Implement changes from code review

* Update strings/is_valid_email_address.py

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* chore(is_valid_email_address): Fix ruff error

* Update strings/is_valid_email_address.py

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-08-14 01:28:52 -07:00
Christian Clauss
dbaff34572
Fix ruff rules ISC flake8-implicit-str-concat (#8892) 2023-07-28 17:53:09 +01:00
Caeden Perelli-Harris
93fb169627
[Upgrade Ruff] Fix all errors raised from ruff (#8879)
* chore: Fix tests

* chore: Fix failing ruff

* chore: Fix ruff errors

* chore: Fix ruff errors

* chore: Fix ruff errors

* chore: Fix ruff errors

* chore: Fix ruff errors

* chore: Fix ruff errors

* chore: Fix ruff errors

* chore: Fix ruff errors

* chore: Fix ruff errors

* chore: Fix ruff errors

* chore: Fix ruff errors

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* chore: Fix ruff errors

* chore: Fix ruff errors

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update cellular_automata/game_of_life.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* chore: Update ruff version in pre-commit

* chore: Fix ruff errors

* Update edmonds_karp_multiple_source_and_sink.py

* Update factorial.py

* Update primelib.py

* Update min_cost_string_conversion.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>
2023-07-22 12:05:10 +02:00
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
Caeden Perelli-Harris
cfbbfd9896
Merge and add benchmarks to palindrome algorithms in the strings/ directory (#8749)
* refactor: Merge and add benchmarks to palindrome

* updating DIRECTORY.md

* chore: Fix failing tests

* Update strings/palindrome.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update palindrome.py

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2023-05-25 12:56:23 +02:00
Margaret
997d56fb63
Switch case (#7995) 2023-05-11 06:53:47 +12:00
Christian Clauss
4c1f876567
Solving the Top k most frequent words problem using a max-heap (#8685)
* 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>
2023-04-27 23:02:07 +05:30
Christian Clauss
c96241b5a5
Replace bandit, flake8, isort, and pyupgrade with ruff (#8178)
* Replace bandit, flake8, isort, and pyupgrade with ruff

* Comment on ruff rules

* updating DIRECTORY.md

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2023-03-15 13:58:25 +01: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
Christian Clauss
c909da9b08
pre-commit: Upgrade psf/black for stable style 2023 (#8110)
* 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>
2023-02-01 18:44:54 +05:30
Abhishek Mulik
32a1ff9359
Update is_palindrome.py (#8022) 2023-01-04 13:47:15 +13:00
Mark Mayo
f32d611689
clean of unnecessary checks, imports, calls (#7993) 2022-11-21 00:00:27 +13:00
Caeden Perelli-Harris
daa1c7529a
Raise error not string (#7945)
* ci: Add `B023` to `.flake8` ignores

* refactor: Return `bool`/raise Exception

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* revert: Remove previous branch commit

* Update data_structures/binary_tree/segment_tree_other.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* feat: Apply `__repr__` changes

* chore: Fix failing tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update data_structures/binary_tree/segment_tree_other.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* test: Fix doctests

* random.choice(population_score[:N_SELECTED])[0]

* Update basic_string.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>
2022-11-06 15:54:44 +01:00
ok-open-sc
0c5f1c0130
Increased Readability Of Variables (#6400)
* Increased Readability Of Variables

* Update anagrams.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update anagrams.py

* [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>
2022-10-30 08:11:17 +01:00
Harsh Verma
a02e7a1331
Added algorithm for Text Justification in Strings (#7354)
* Added algorithm for Text Justification in Strings

* Added algorithm for Text Justification in Strings
2022-10-29 15:54:32 +02:00
Sineth Sankalpa
327c38d6f0
Srilankan phone number validation (#7706)
* Add is_srilankan_phone_number.py

* Update is_srilankan_phone_number.py
2022-10-29 14:40:14 +02:00
Christian Clauss
19bff003aa
Adopt Python >= 3.8 assignment expressions using auto-walrus (#7737)
* 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>
2022-10-28 15:54:54 +02:00
SwayamSahu
de3271ec80
Refactoring the syntax using list comprehension (#7749)
* Refactoring the syntax using list comprehension

* Update detecting_english_programmatically.py

* Update detecting_english_programmatically.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2022-10-27 23:02:15 +02:00
Caeden Perelli-Harris
9bba42eca8
refactor: Indent ... for visual purposes (#7744) 2022-10-27 19:42:30 +02:00
SwayamSahu
71c7c0bd35
Updated a typo in print statement (#7696)
* Updated a typo in print statement

* Apply suggestions from code review

Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>
2022-10-26 22:20:00 +02:00