Created
January 25, 2020 20:24
-
-
Save LucasMagnum/6a17095da4928afb670cdbdcc7acf4bd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Dado um string S, retorne True se todos os caracters forem | |
únicos e False caso exista algum duplicado. | |
Valores em minúsculo e maiúsculo são considerados os mesmos. | |
Ex: | |
>> is_unique("lucas") | |
True | |
>> is_unique("lucasS") | |
False | |
""" | |
import sys | |
def is_unique(string: str) -> bool: | |
character_seen = {} | |
for character in string: | |
if character_seen.get(character): | |
return False | |
character_seen[character] = True | |
return True | |
if __name__ == "__main__": | |
try: | |
string = sys.argv[1] | |
except IndexError: | |
string = "lucas" | |
print(f"is_unique({string}) -> ", is_unique(string)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment