13 challenges match these filters
max_window_sum(nums, k) should return the largest sum of any k consecutive numbers. max_window_sum([1,2,3,10], 2) is 13.
Off-by-one
count_in_range(nums, low, high) counts values between low and high INCLUSIVE, so count_in_range([1,2,3], 1, 3) returns 3.
Off-by-one
chunk(items, size) should split a list into groups of size, keeping any short final group. chunk([1,2,3,4,5], 2) gives [[1,2],[3,4],[5]].
Off-by-one
last_char(text) should return the final character, so last_char("hello") returns "o".
Off-by-one
joinWithDash(words) should join words with dashes between them, so joinWithDash(["a","b"]) returns "a-b".
Off-by-one
pageItems(items, page, size) returns one page of results. Pages are numbered from 1, so pageItems([1,2,3,4,5,6], 1, 3) gives [1,2,3].
Off-by-one
sumAll(nums) should add up every number in the array, so sumAll([1, 2, 3]) returns 6.
Off-by-one
capitalize(word) should upper-case the first letter, so "debug" becomes "Debug".
Off-by-one
last_n_chars(text, n) should return the last n characters of a string, so last_n_chars("debugging", 3) gives "ing".
Off-by-one
binary_search(nums, target) should return the index of target in a sorted list, or -1 if it isn't there.
Off-by-one
firstChunk(arr, size) should return the first `size` items of an array, so firstChunk([1,2,3,4,5], 3) gives [1,2,3].
Off-by-one
getLastNItems(arr, n) should return the last n items of arr, e.g. getLastNItems([1,2,3,4,5], 2) -> [4, 5].
Off-by-one
sum_range(n) should return the sum of all integers from 1 to n, inclusive.
Off-by-one