|
def f(lists):
dic = {}
for n in lists:
if n in dic:
dic[n].append(lists.pop(lists.index(n)))
else:
dic[n] = lists[:lists.index(n) + 1]
return str(dic).replace(' ', '')
assert f([5, 2, 7, 2, 3, 5]) == '{5:[5,5],2:[5,2,2],7:[5,2,7]}'
|
CRUXEval-I
assert f(??) == '{5:[5,5],2:[5,2,2],7:[5,2,7]}'
|
CRUXEval-O
assert f([5, 2, 7, 2, 3, 5]) == ??
|