Skip to content

Instantly share code, notes, and snippets.

@LucasMagnum
Created January 25, 2020 20:24
Show Gist options
  • Save LucasMagnum/6a17095da4928afb670cdbdcc7acf4bd to your computer and use it in GitHub Desktop.
Save LucasMagnum/6a17095da4928afb670cdbdcc7acf4bd to your computer and use it in GitHub Desktop.
"""
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