题解 | #简单错误记录#
简单错误记录
http://www.nowcoder.com/practice/2baa6aba39214d6ea91a2e03dff3fbeb
import sys
my_dict = {}
mistake = []
value = []
while True:
line = sys.stdin.readline().strip().split('\\')[-1]
if line == '':
break
elif line in mistake:
value[mistake.index(line)] = value[mistake.index(line)] + 1
else:
mistake.append(line)
value.append(1)
for i in range(len(mistake)):
item = mistake[i].split()[0]
if len(item) > 16:
newitem = item[-16:] + ' ' + mistake[i].split()[1]
if newitem in mistake:
value[mistake.index(newitem)] = value[mistake.index(newitem)] + 1
value.pop(i)
mistake.pop(i)
else:
mistake[i] = newitem
if len(mistake) > 8:
re_mistake = mistake[-8:]
re_value = value[-8:]
else:
re_mistake = mistake
re_value = value
for i in range(len(re_value)):
print(re_mistake[i] + ' ' + str(re_value[i]))