46 challenges match these filters
total_values(data) should add up a dictionary's values, so total_values({'a': 1, 'b': 2}) returns 3.
Other
sorted_names(names) should return the names in alphabetical order, so sorted_names(["b","a"]) returns ["a","b"].
Other
The function copies a grid, edits the copy, then reports the ORIGINAL's first cell — which should be unchanged. For [[1,2],[3,4]] it returns 1.
Other
safe_ratio(a, b) should return True when a / b is greater than 1, and False when b is zero rather than crashing.
Logic error
largest_gap(nums) should return the biggest jump between consecutive values in an ascending list, so largest_gap([1, 5, 6]) returns 4.
Logic error
all_positive(nums) should return True only when EVERY number is greater than zero.
Logic error
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
total_score(scores, names) should add up the scores for the named players, treating anyone without a score as 0.
Null / Undefined
first_match(items, target) should return the first matching item, or -1 when there is no match.
Null / Undefined
describe_temp(readings, station) should report 'recorded' whenever that station reported a temperature — including a reading of 0 degrees — and 'missing' only when the station is absent.
Null / Undefined
retries_for(config) should use config['retries'] when present and default to 3 when it is missing. A value of 0 means 'do not retry'.
Null / Undefined
middle_item(items) should return the middle element, so middle_item([1, 2, 3]) returns 2.
Type error
count_above(values, threshold) counts how many values exceed the threshold. The values arrive as strings from a form, so count_above(["1", "5", "10"], 3) should return 2.
Type error
total_for_ids(counts, ids) totals the counts for the given ids. counts comes from a JSON payload, e.g. {"1": 10, "2": 20}, and ids are integers.
Type error
highest(values) should return the largest number from a list of numeric strings, so highest(["9", "10", "2"]) returns "10".
Type error
shrink_to_one(n) applies the Collatz rule — halve even numbers, and turn odd n into 3n + 1 — counting steps until n reaches 1. shrink_to_one(6) returns 8.
Infinite loop
attempts_until_success(n) retries until the nth attempt succeeds and returns the number of tries, so attempts_until_success(3) returns 3.
Infinite loop
squash_spaces(text) should collapse runs of spaces into one, so squash_spaces("a b") returns "a b".
Infinite loop
count_pairs(nums, target) should count the pairs that add up to target, so count_pairs([1, 2, 3], 4) returns 1.
Infinite loop
Each Basket should have its own items, so after adding one thing to a fresh basket, two_baskets('x', 'y') returns 1.
Scope error
add_all(nums) should return the sum of the numbers, so add_all([1, 2, 3]) returns 6.
Scope error