Skip to content

Instantly share code, notes, and snippets.

@rayansostenes
Forked from antonioFlavio/URI_1211.py
Created March 1, 2019 02:31
Show Gist options
  • Save rayansostenes/6ae81d6e51f00247b46e5d2186c08487 to your computer and use it in GitHub Desktop.
Save rayansostenes/6ae81d6e51f00247b46e5d2186c08487 to your computer and use it in GitHub Desktop.
while True:
try:
num = int(input() or 0)
except EOFError:
num = 0
if not num:
break
chars_saved = 0
last_phone = None
phone_list = [input() for _ in range(num)]
phone_list.sort()
for phone in phone_list:
if last_phone is None:
last_phone = phone
continue
# compara as strings
for new_phone_char, last_phone_char in zip(phone, last_phone):
if new_phone_char == last_phone_char:
chars_saved += 1
else:
break
last_phone = phone
print(chars_saved)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment