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

Added swap case program and removed unexpected expression part #3212

Merged
merged 25 commits into from
Oct 14, 2020

Conversation

mayur200
Copy link
Contributor

Describe your change:

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?
  • I have added an algorithm for swap case in string folder
  • This pull request is all my own work -- I have not plagiarized.
  • I have fixed unexpected expression part from 2 algorithm.
  • All functions and variable names follow Python naming conventions.

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

@mayur200 mayur200 requested a review from cclauss as a code owner October 11, 2020 22:13
@TravisBuddy
Copy link

Travis tests have failed

Hey @mayur200,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: f141dbc0-0c0f-11eb-a59b-f3f3774a9991

@@ -42,4 +42,4 @@ def cocktail_shaker_sort(unsorted: list) -> list:
doctest.testmod()
user_input = input("Enter numbers separated by a comma:\n").strip()
unsorted = [int(item) for item in user_input.split(",")]
print(f"{cocktail_shaker_sort(unsorted) = }")
print(f"{cocktail_shaker_sort(unsorted) }")
Copy link
Member

Choose a reason for hiding this comment

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

Why break this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was getting error in pycharm 'unexpected expression part' before running a program.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have fixed it again and I have commited changes. Sorry for the inconvenience

@@ -39,4 +39,4 @@ def naive_pattern_search(s: str, pattern: str) -> list:

if __name__ == "__main__":
assert naive_pattern_search("ABCDEFG", "DE") == [3]
print(f"{naive_pattern_search('ABAAABCDBBABCDDEBCABC', 'ABC') = }")
print(f"{naive_pattern_search('ABAAABCDBBABCDDEBCABC', 'ABC')}")
Copy link
Member

Choose a reason for hiding this comment

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

Why break this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was getting error in pycharm 'unexpected expression part' before running a program.

Copy link
Member

Choose a reason for hiding this comment

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

Pycharm is not upgraded to Python 3.8 and 3.9 which support this functionality.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have fixed this

"""
if len(sentence) < 1001:
newstring = ''
for word in sentence:
Copy link
Member

Choose a reason for hiding this comment

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

These are not words. They are char.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok. I will fix it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have fixed it and commit the changes

Comment on lines 40 to 41
else:
raise Exception("Charater length should be between 1 and 1000")
Copy link
Member

Choose a reason for hiding this comment

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

Why?

Copy link
Contributor Author

@mayur200 mayur200 Oct 13, 2020

Choose a reason for hiding this comment

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

I have raise an exception and its readable. If its not relatable should I remove it?

Copy link
Member

Choose a reason for hiding this comment

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

No. I mean why create a 1000 character limit? Just process the string no matter how long it is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have removed condition

def swap_case(sentence):
"""
This function will convert all lowercase letters to uppercase letters and vice versa.
>>>swap_case('Algorithm.Python@89')
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
>>>swap_case('Algorithm.Python@89')
>>> swap_case('Algorithm.Python@89')

Without the space, the test is never run.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will fix it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added space. I have commited changes

2)>>>Please input sentence: github.com/mayur200
GITHUB.COM/MAYUR200

Constraints: Length of string should between 1 and 1000
Copy link
Member

Choose a reason for hiding this comment

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

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its example for problem statement. If someone failed to understand the problem. This example is self explanatory

Copy link
Member

Choose a reason for hiding this comment

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

No. I mean why create a 1000 character limit? Just process the string no matter how long it is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. I will fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have fixed it and I have pushed changes

@cclauss
Copy link
Member

cclauss commented Oct 12, 2020

All tests are failing.

@mayur200 mayur200 requested a review from l3str4nge as a code owner October 14, 2020 20:02
@TravisBuddy
Copy link

Travis tests have failed

Hey @mayur200,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: 1e9101f0-0e59-11eb-964d-5d54b4986782

@TravisBuddy
Copy link

Travis tests have failed

Hey @mayur200,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: 7a45e010-0e59-11eb-964d-5d54b4986782

@TravisBuddy
Copy link

Travis tests have failed

Hey @mayur200,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: 790c3220-0e5a-11eb-964d-5d54b4986782

@TravisBuddy
Copy link

Travis tests have failed

Hey @mayur200,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: 0603d7a0-0e5b-11eb-964d-5d54b4986782

@TravisBuddy
Copy link

Travis tests have failed

Hey @mayur200,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: 4eda6340-0e5b-11eb-964d-5d54b4986782

@TravisBuddy
Copy link

Travis tests have failed

Hey @mayur200,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: bff9e410-0e5b-11eb-964d-5d54b4986782

@TravisBuddy
Copy link

Travis tests have failed

Hey @mayur200,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: 9ed5bd80-0e5c-11eb-964d-5d54b4986782

@TravisBuddy
Copy link

Travis tests have failed

Hey @mayur200,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: 913ca430-0e5d-11eb-964d-5d54b4986782

@TravisBuddy
Copy link

Travis tests have failed

Hey @mayur200,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: 8be5a5d0-0e5e-11eb-964d-5d54b4986782

@mayur200
Copy link
Contributor Author

Why my test is failed again??
I am confused I don't know why its failed my program gives me perfect output

@cclauss
Copy link
Member

cclauss commented Oct 14, 2020

https://travis-ci.com/github/TheAlgorithms/Python/jobs/399797450#L775

@TravisBuddy
Copy link

Travis tests have failed

Hey @mayur200,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: cc658370-0e66-11eb-964d-5d54b4986782

@TravisBuddy
Copy link

Travis tests have failed

Hey @mayur200,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: df9cfd00-0e67-11eb-964d-5d54b4986782

@TravisBuddy
Copy link

Travis tests have failed

Hey @mayur200,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: 4faa06f0-0e69-11eb-964d-5d54b4986782

@TravisBuddy
Copy link

Travis tests have failed

Hey @mayur200,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: 08950c00-0e6a-11eb-964d-5d54b4986782

@cclauss cclauss merged commit ed30749 into TheAlgorithms:master Oct 14, 2020
stokhos pushed a commit to stokhos/Python that referenced this pull request Jan 3, 2021
…gorithms#3212)

* Removed an extra '=' which was creating an error while running a program.

* Removed the unexpected expression part.

* Added program for swap cases in string folder

* removed if condition and exchange word with char

* added '=' sign which I removed before because of unknowing error from pycharm

* added space in test

* removed costraint from problem statement

* Update cocktail_shaker_sort.py

* Update naive_string_search.py

* Update swap_case.py

* psf/black " not '

* added new line at the end of the file

* Fix flake8 issues

* added new line at the end of the file

* added True and fixed comment

* python file end with \n

* Update swap_case.py

* Update strings/swap_case.py

* Update strings/swap_case.py

* Apply suggestions from code review

* Update strings/swap_case.py

* Update swap_case.py

* Update swap_case.py

Co-authored-by: Christian Clauss <cclauss@me.com>
Panquesito7 pushed a commit to Panquesito7/Python that referenced this pull request May 13, 2021
…gorithms#3212)

* Removed an extra '=' which was creating an error while running a program.

* Removed the unexpected expression part.

* Added program for swap cases in string folder

* removed if condition and exchange word with char

* added '=' sign which I removed before because of unknowing error from pycharm

* added space in test

* removed costraint from problem statement

* Update cocktail_shaker_sort.py

* Update naive_string_search.py

* Update swap_case.py

* psf/black " not '

* added new line at the end of the file

* Fix flake8 issues

* added new line at the end of the file

* added True and fixed comment

* python file end with \n

* Update swap_case.py

* Update strings/swap_case.py

* Update strings/swap_case.py

* Apply suggestions from code review

* Update strings/swap_case.py

* Update swap_case.py

* Update swap_case.py

Co-authored-by: Christian Clauss <cclauss@me.com>
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.

3 participants