Run #9a85cf4c
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
from itertools import pairwise
def solve(input):
if not input:
return []
return [input[0]] + [b - a for a, b in pairwise(input)]Score Difference
Tied
Runtime Advantage
2μs slower
Code Size
6 vs 9 lines
| # | Your Solution | # | Champion |
|---|---|---|---|
| 1 | from itertools import pairwise | 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 | return [input[0]] + [b - a for a, b in pairwise(input)] | 6 | for current in input[1:]: |
| 7 | 7 | result.append(current - previous) | |
| 8 | 8 | previous = current | |
| 9 | 9 | return result |
1from itertools import pairwise23def solve(input):4 if not input:5 return []6 return [input[0]] + [b - a for a, b in pairwise(input)]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