Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Add] : Wildcard Matching program under DYNAMIC PROGRAMMING #10403

Merged
merged 7 commits into from
Oct 15, 2023
Merged

[Add] : Wildcard Matching program under DYNAMIC PROGRAMMING #10403

merged 7 commits into from
Oct 15, 2023

Conversation

kosuri-indu
Copy link
Contributor

@kosuri-indu kosuri-indu commented Oct 14, 2023

Describe your change:

This PR adds the wildcard matching program under dynamic programming.

Wildcard Matching :

image

wildcard-pattern-matching

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms include at least one URL that points to Wikipedia or another similar explanation.
  • If this pull request resolves one or more open issues then the description above includes the issue number(s) with a closing keyword: "Fixes #ISSUE-NUMBER".

@algorithms-keeper algorithms-keeper bot added the tests are failing Do not merge until tests pass label Oct 14, 2023
@algorithms-keeper algorithms-keeper bot added the awaiting reviews This PR is ready to be reviewed label Oct 14, 2023
@algorithms-keeper algorithms-keeper bot removed the tests are failing Do not merge until tests pass label Oct 14, 2023
@kosuri-indu kosuri-indu changed the title [Add ] : To add Wildcard Matching program under DYNAMIC PROGRAMMING [Add ] : Wildcard Matching program under DYNAMIC PROGRAMMING Oct 14, 2023
@kosuri-indu kosuri-indu changed the title [Add ] : Wildcard Matching program under DYNAMIC PROGRAMMING [Add] : Wildcard Matching program under DYNAMIC PROGRAMMING Oct 14, 2023
@kosuri-indu
Copy link
Contributor Author

Hey @cclauss , Could you review this pull request and suggest any changes ?

@cclauss
Copy link
Member

cclauss commented Oct 15, 2023

Please add some timeit benchmarks so we can see its relative performance vs. strings/wildcard_pattern_matching.py

@cclauss cclauss self-assigned this Oct 15, 2023
@kosuri-indu
Copy link
Contributor Author

kosuri-indu commented Oct 15, 2023

Please add some timeit benchmarks so we can see its relative performance vs. strings/wildcard_pattern_matching.py

* https://github.com/search?q=repo%3ATheAlgorithms%2FPython%20timeit&type=code

@cclauss , could you check the code I wrote in the picture , is it correct way ?

image

@cclauss
Copy link
Member

cclauss commented Oct 15, 2023

Please do not paste in pictures of code because they hare not searchable and not editable.
What were the results when you ran the benchmark?

@kosuri-indu
Copy link
Contributor Author

kosuri-indu commented Oct 15, 2023

Please do not paste in pictures of code because they hare not searchable and not editable. What were the results when you ran the benchmark?

@cclauss Sorry, will not do that next time.

The previous timeit benchmark code showed an error , so I tried a different code

This is the code I used :

from timeit import timeit
from strings import wildcard_pattern_matching

def benchmark() -> None:
    print("Running performance benchmarks...")

    print("> is_pattern_match(): ", end="")
    print(timeit(lambda: is_pattern_match('aa','*'), number=10000))

    print("> wildcard_pattern_matching.match_pattern(): ", end="")
    print(timeit(lambda: wildcard_pattern_matching.match_pattern('aa','*'), number=10000))

if __name__ == "__main__":
    import doctest
    doctest.testmod()
    benchmark()

Results :
is_pattern_match() : this repo program
wildcard_pattern_matching.match_pattern() : strings/wildcard_pattern_matching.py

 Running performance benchmarks...
> is_pattern_match(): 0.04153230000520125
> wildcard_pattern_matching.match_pattern(): 0.07759870000882074
Running performance benchmarks...
> is_pattern_match(): 0.02651770002557896
> wildcard_pattern_matching.match_pattern(): 0.07914639997761697
Running performance benchmarks...
> is_pattern_match(): 0.0210864000255242
> wildcard_pattern_matching.match_pattern(): 0.04255719998036511

@kosuri-indu kosuri-indu requested a review from cclauss October 15, 2023 10:10
@algorithms-keeper algorithms-keeper bot added tests are failing Do not merge until tests pass and removed tests are failing Do not merge until tests pass labels Oct 15, 2023
@algorithms-keeper algorithms-keeper bot removed the awaiting reviews This PR is ready to be reviewed label Oct 15, 2023
@cclauss cclauss merged commit 89d12df into TheAlgorithms:master Oct 15, 2023
sedatguzelsemme pushed a commit to sedatguzelsemme/Python that referenced this pull request Sep 15, 2024
…ithms#10403)

* To add wildcard_matching.py

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

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

* changes for doctest errors

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

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

* code changes

* [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>
@isidroas isidroas mentioned this pull request Jan 25, 2025
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants