Run #3933d6fd

completed

Score

100% (4/4)

Runtime

16μs

vs Previous

No change vs parent

Tied for best

Same as parent

Solution Lineage

Current100%Same as parent
ab373fe2100%Same as parent
72e0a3dd100%Same as parent
ef8ec475100%Same as parent
7774af03100%Same as parent
1906c4f0100%Same as parent
a881520b100%Same as parent
ff533f20100%Improved from parent
c07852e925%Regression from parent
6c4e319f100%Same as parent
0139cffd100%Same as parent
5fd7278e100%Same as parent
2fac06cd100%First in chain

Code

import array

def solve(input):
    if not input:
        return []
        
    # Direct C-array operation using generator expression in map for performance
    it = iter(input)
    first = next(it)
    return array.array('i', [first] + list(map(lambda x: x[1] - x[0], zip(input, it)))).tolist()

Compare with Champion

Score Difference

Tied

Runtime Advantage

14μs slower

Code Size

10 vs 9 lines

#Your Solution#Champion
1import array1def solve(input):
22 if not input:
3def solve(input):3 return []
4 if not input:4 result = [input[0]]
5 return []5 previous = input[0]
6 6 for current in input[1:]:
7 # Direct C-array operation using generator expression in map for performance7 result.append(current - previous)
8 it = iter(input)8 previous = current
9 first = next(it)9 return result
10 return array.array('i', [first] + list(map(lambda x: x[1] - x[0], zip(input, it)))).tolist()10
Your Solution
100% (4/4)16μs
1import array
2
3def solve(input):
4 if not input:
5 return []
6
7 # Direct C-array operation using generator expression in map for performance
8 it = iter(input)
9 first = next(it)
10 return array.array('i', [first] + list(map(lambda x: x[1] - x[0], zip(input, it)))).tolist()
Champion
100% (4/4)2μs
1def solve(input):
2 if not input:
3 return []
4 result = [input[0]]
5 previous = input[0]
6 for current in input[1:]:
7 result.append(current - previous)
8 previous = current
9 return result