Skip to content

Conversation

@RohitSingh107
Copy link
Contributor

Describe your change:

  • 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 have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.
@algorithms-keeper algorithms-keeper bot added the require type hints https://docs.python.org/3/library/typing.html label Oct 21, 2022
Copy link

@algorithms-keeper algorithms-keeper bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

"""


def longest_common_substring(t1: str, t2: str):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: longest_common_substring. If the function does not return a value, please provide the type hint as: def function() -> None:

@algorithms-keeper algorithms-keeper bot added the awaiting reviews This PR is ready to be reviewed label Oct 21, 2022
@algorithms-keeper algorithms-keeper bot removed the require type hints https://docs.python.org/3/library/typing.html label Oct 21, 2022
RohitSingh107 and others added 9 commits October 22, 2022 12:13
Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>
Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>
Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>
Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>
Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>
Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>
Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>
Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>
Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>
@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 22, 2022
RohitSingh107 and others added 4 commits October 22, 2022 12:18
Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>
Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>
@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 22, 2022
@ChrisO345
Copy link
Collaborator

What happens if an invalid input is used? For example: longest_common_substring(1, 2)?

@RohitSingh107
Copy link
Contributor Author

It will throw error as type hints say it should be a string.

@ChrisO345
Copy link
Collaborator

That's not the reason why an error is thrown. Type hints are used to make code more readable. Python is statically typed so the code runs and an error is thrown when it attempts to perform len() on an integer. https://www.geeksforgeeks.org/type-hints-in-python/

@RohitSingh107
Copy link
Contributor Author

so what should I do? adding an assert that it should be a string?

@RohitSingh107
Copy link
Contributor Author

Why pr is not progressing, is it something that needs to change or be modified?

Copy link
Contributor

@CaedenPH CaedenPH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cclauss Can we get your review please

Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>
@algorithms-keeper algorithms-keeper bot added the tests are failing Do not merge until tests pass label Oct 23, 2022
@RohitSingh107
Copy link
Contributor Author

Does this come from the second solution of https://www.geeksforgeeks.org/longest-common-substring-dp-29 Given the test data includes that site, it probably does. The source or inspiration should be acknowledged in the comments.

No, it's my original work, I haven't even seen this algorithm before writing on my own. I have only just taken test cases to test my algorithm and nothing else.

@algorithms-keeper algorithms-keeper bot removed the tests are failing Do not merge until tests pass label Oct 23, 2022
@algorithms-keeper algorithms-keeper bot added awaiting changes A maintainer has requested changes to this PR and removed awaiting reviews This PR is ready to be reviewed labels Oct 23, 2022
@algorithms-keeper algorithms-keeper bot added awaiting reviews This PR is ready to be reviewed and removed awaiting changes A maintainer has requested changes to this PR labels Oct 23, 2022
@algorithms-keeper algorithms-keeper bot removed the awaiting reviews This PR is ready to be reviewed label Oct 23, 2022
@cclauss cclauss self-requested a review October 23, 2022 17:49
@cclauss cclauss requested review from CaedenPH and ChrisO345 and removed request for CaedenPH and ChrisO345 October 23, 2022 17:49
@ChrisO345 ChrisO345 dismissed their stale review October 23, 2022 21:59

out of date

Copy link
Member

@poyea poyea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your pull request!🤩

@poyea poyea changed the title added longest common substring Add longest common substring Oct 25, 2022
@poyea poyea merged commit c31ef5e into TheAlgorithms:master Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

5 participants