Run #c4e4a49b
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):
deltas = array.array('i', (0, ) * len(input))
if len(input) > 0:
deltas[0] = input[0]
for i in range(1, len(input)):
deltas[i] = input[i] - input[i - 1]
return deltas.tolist()Score Difference
Tied
Runtime Advantage
8μs slower
Code Size
9 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 | deltas = array.array('i', (0, ) * len(input)) | 4 | result = [input[0]] |
| 5 | if len(input) > 0: | 5 | previous = input[0] |
| 6 | deltas[0] = input[0] | 6 | for current in input[1:]: |
| 7 | for i in range(1, len(input)): | 7 | result.append(current - previous) |
| 8 | deltas[i] = input[i] - input[i - 1] | 8 | previous = current |
| 9 | return deltas.tolist() | 9 | return result |
1import array23def solve(input):4 deltas = array.array('i', (0, ) * len(input))5 if len(input) > 0:6 deltas[0] = input[0]7 for i in range(1, len(input)):8 deltas[i] = input[i] - input[i - 1]9 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