Run #57767fcb
completedScore
100% (4/4)
Runtime
10μs
vs Previous
No change vs parent
Tied for best
Same as parent
Score
100% (4/4)
Runtime
10μs
vs Previous
No change vs parent
Tied for best
Same as parent
import array
def solve(input):
if not input:
return []
delta_encoded = array.array('i', [0]) * len(input)
delta_encoded[0] = input[0]
for i in range(1, len(input)):
delta_encoded[i] = input[i] - input[i - 1]
return list(delta_encoded)Score Difference
Tied
Runtime Advantage
8μs slower
Code Size
10 vs 9 lines
| # | Your Solution | # | Champion |
|---|---|---|---|
| 1 | import array | 1 | def solve(input): |
| 2 | 2 | if not input: | |
| 3 | def solve(input): | 3 | return [] |
| 4 | if not input: | 4 | result = [input[0]] |
| 5 | return [] | 5 | previous = input[0] |
| 6 | delta_encoded = array.array('i', [0]) * len(input) | 6 | for current in input[1:]: |
| 7 | delta_encoded[0] = input[0] | 7 | result.append(current - previous) |
| 8 | for i in range(1, len(input)): | 8 | previous = current |
| 9 | delta_encoded[i] = input[i] - input[i - 1] | 9 | return result |
| 10 | return list(delta_encoded) | 10 |
1import array23def solve(input):4 if not input:5 return []6 delta_encoded = array.array('i', [0]) * len(input)7 delta_encoded[0] = input[0]8 for i in range(1, len(input)):9 delta_encoded[i] = input[i] - input[i - 1]10 return list(delta_encoded)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 = current9 return result