12 challenges match these filters
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
countUppercase(text) should count the uppercase letters, so countUppercase("aBc") returns 1.
Infinite loop
squash_spaces(text) should collapse runs of spaces into one, so squash_spaces("a b") returns "a b".
Infinite loop
stepsToExceed(limit) counts how many times you must double 1 before passing limit, so stepsToExceed(8) returns 4.
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
indexOfValue(sorted, target) should return the index of target in a sorted array, or -1 if it is absent.
Infinite loop
countOdds(nums) should count the odd numbers, so countOdds([1, 2, 3]) returns 2.
Infinite loop
dedupe(arr) should return the array with duplicates removed, keeping the first occurrence of each value.
Infinite loop
reverseString(text) should return the string backwards, so "abc" becomes "cba".
Infinite loop
sum_digits(n) should add up the digits of a number, so sum_digits(123) gives 6.
Infinite loop
countdown(n) should return a list counting down from n to 1, e.g. countdown(3) -> [3, 2, 1].
Infinite loop