Skip to content

Fixed remove duplicate #2470

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

Merged
merged 2 commits into from
Sep 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bit_manipulation/binary_and_operator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# https://www.tutorialspoint.com/python3/bitwise_operators_example.htm


def binary_and(a: int, b: int):
"""
Take in 2 integers, convert them to binary,
Expand Down
1 change: 1 addition & 0 deletions bit_manipulation/binary_xor_operator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# https://www.tutorialspoint.com/python3/bitwise_operators_example.htm


def binary_xor(a: int, b: int):
"""
Take in 2 integers, convert them to binary,
Expand Down
13 changes: 7 additions & 6 deletions strings/remove_duplicate.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
""" Created by sarathkaul on 14/11/19 """


def remove_duplicates(sentence: str) -> str:
"""
Reomove duplicates from sentence
Remove duplicates from sentence
>>> remove_duplicates("Python is great and Java is also great")
'Java Python also and great is'
>>> remove_duplicates("Python is great and Java is also great")
'Java Python also and great is'
"""
return " ".join(sorted(set(sentence.split(" "))))
return " ".join(sorted(set(sentence.split())))


if __name__ == "__main__":
print(remove_duplicates("INPUT_SENTENCE"))
Copy link
Member

Choose a reason for hiding this comment

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

Why remove this line? Without it, the user runs the program and nothing happens.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think algorithm should not print anything. Because it have tested it using doctest.

Copy link
Member

@cclauss cclauss Sep 24, 2020

Choose a reason for hiding this comment

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

The algorithmic function does not print() in alignment with CONTRIBUTING.md. The algorithmic function instead returns a string. However, it is more instructive (and intuitive) for the reader if main() does print the result of the algorithm. We are writing for humans to learn, not merely or computers to test.

import doctest

doctest.testmod()