In [159]:
def cache():
cache_size = int(input())
raw_cities = input()
raw_cities = list(raw_cities[raw_cities.index('[')+1 : raw_cities.index(']')].split(","))
cache = []
running_time = []
for i in raw_cities:
i = i[i.index('“')+1 : i.index('”')]
i = i.upper()
if len(cache[0:cache_size+1]) < cache_size or cache_size == 0:
cache.insert(0,i)
running_time.append(5)
elif i in cache[0:cache_size+1]:
cache.insert(0,i)
running_time.append(1)
else:
cache.insert(0,i)
running_time.append(5)
return sum(running_time)
In [166]:
print(cache())
In [167]:
print(cache())
In [168]:
print(cache())
In [169]:
print(cache())
In [170]:
print(cache())
In [171]:
print(cache())