19 lines
563 B
Python
19 lines
563 B
Python
# HumanEval/37
|
|
# Loki Mode Multi-Agent Solution
|
|
# Attempts: 1
|
|
# Passed: True
|
|
|
|
def sort_even(l: list):
|
|
"""This function takes a list l and returns a list l' such that
|
|
l' is identical to l in the odd indicies, while its values at the even indicies are equal
|
|
to the values of the even indicies of l, but sorted.
|
|
>>> sort_even([1, 2, 3])
|
|
[1, 2, 3]
|
|
>>> sort_even([5, 6, 3, 4])
|
|
[3, 6, 5, 4]
|
|
"""
|
|
even_elements = sorted(l[::2])
|
|
result = l[:]
|
|
for i, val in enumerate(even_elements):
|
|
result[i * 2] = val
|
|
return result |