dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
1.4 KiB
1.4 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 69f8c998d78ad3171a0713bc | Challenge 289: Sum of Differences | 29 | challenge-289 |
--description--
Given an array of numbers, return the sum of the differences between each number and the one that follows it.
For example, given [1, 3, 4], return 3 (2 + 1).
--hints--
sum_of_differences([1, 3, 4]) should return 3.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(sum_of_differences([1, 3, 4]), 3)`)
}})
sum_of_differences([5, -3, 3, 9, 10]) should return 5.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(sum_of_differences([5, -3, 3, 9, 10]), 5)`)
}})
sum_of_differences([9, 6, 15, -20, 33, 14, 25, 16, -7]) should return -16.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(sum_of_differences([9, 6, 15, -20, 33, 14, 25, 16, -7]), -16)`)
}})
sum_of_differences([50, 102, -46, 82, -49, 29, 71, 902, -237, 111, -61, 75]) should return 25.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(sum_of_differences([50, 102, -46, 82, -49, 29, 71, 902, -237, 111, -61, 75]), 25)`)
}})
--seed--
--seed-contents--
def sum_of_differences(arr):
return arr
--solutions--
def sum_of_differences(arr):
return sum(arr[i + 1] - arr[i] for i in range(len(arr) - 1))