Every callback reports the same index
collectIndexes(n) should schedule one callback per index and resolve to the list of indexes, so collectIndexes(3) gives [0, 1, 2].
Filter by language, bug pattern or difficulty
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
addRounded(a, b) should add two numbers and return the result rounded to two decimal places, as a number. addRounded(1, 2) is 3.
Other
stripDashes(text) should remove every dash, so stripDashes("a-b-c") returns "abc".
Other
isAvailable(item) should be true only when the item is in stock AND not discontinued.
Logic error
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
percentChange(oldValue, newValue) should report the change as a percentage of the old value. Going from 100 to 150 is +50.
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
joinWithDash(words) should join words with dashes between them, so joinWithDash(["a","b"]) returns "a-b".
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
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
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
sumAll(nums) should add up every number in the array, so sumAll([1, 2, 3]) returns 6.
Off-by-one
cityOf(user) should return the user's city, or "unknown" if any part of the path is missing.
Null / Undefined
priceOf(items, name) should return the named item's price, or 0 when there is no such item.
Null / Undefined
greet(user) should greet the user by name, falling back to "guest" when no name is available.
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