Sitelet https://web.archive.org/web/20260215041828/https://github.com/TheAlgorithms/Python/pull/3694
Skip to content

add min insertions & deletions example#3694

Closed
ankit-bagde wants to merge 2 commits intoTheAlgorithms:masterfrom
ankit-bagde:master
Closed

add min insertions & deletions example#3694
ankit-bagde wants to merge 2 commits intoTheAlgorithms:masterfrom
ankit-bagde:master

Conversation

@ankit-bagde
Copy link

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}.

@ankit-bagde ankit-bagde requested a review from Kush1101 as a code owner October 24, 2020 06:05
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

These are few changes (enhancements). Also please fix your error of trailing whitespaces using a code formatter like black. You can read CONTRIBUTING.md for instructions to use black.

"""


def longest_common_subsequence(str1: str, str2: str):
Copy link

Choose a reason for hiding this comment

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

Suggested change
def longest_common_subsequence(str1: str, str2: str):
def longest_common_subsequence(str1: str, str2: str) -> int:

add type hinting for return value

Comment on lines 78 to 84
>>> min_insertions_deletions(32, "app")
Traceback (most recent call last):
File "min_insertions_deletions.py", line 96, in <module>
insertions, deletions = min_insertions_deletions(str1, str2)
File "min_insertions_deletions.py", line 78, in min_insertions_deletions
assert type(str1) is str, "str1 should be a string, not {}".format(type(str1))
AssertionError: str1 should be a string, not <class 'int'>
Copy link

Choose a reason for hiding this comment

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

Suggested change
>>> min_insertions_deletions(32, "app")
Traceback (most recent call last):
File "min_insertions_deletions.py", line 96, in <module>
insertions, deletions = min_insertions_deletions(str1, str2)
File "min_insertions_deletions.py", line 78, in min_insertions_deletions
assert type(str1) is str, "str1 should be a string, not {}".format(type(str1))
AssertionError: str1 should be a string, not <class 'int'>
>>> min_insertions_deletions(32, "app")
Traceback (most recent call last):
...
AssertionError: str1 should be a string, not <class 'int'>

details are not necessary in doctests

@ankit-bagde
Copy link
Author

Thank you for the suggestions. I have committed the changes

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

@dhruvmanila @poyea @Kush1101, check this out (ready to be merged)

@poyea poyea self-assigned this Oct 24, 2020
@poyea poyea added the hacktoberfest-accepted Accepted to be counted towards Hacktoberfest label Oct 24, 2020
@stale
Copy link

stale bot commented Nov 24, 2020

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Used to mark an issue or pull request stale. label Nov 24, 2020
@stale
Copy link

stale bot commented Dec 6, 2020

Please reopen this pull request once you commit the changes requested or make improvements on the code. If this is not the case and you need some help, feel free to seek help from our Gitter or ping one of the reviewers. Thank you for your contributions!

@stale stale bot closed this Dec 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hacktoberfest-accepted Accepted to be counted towards Hacktoberfest stale Used to mark an issue or pull request stale.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants