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