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