| {"name": "add_two", "prompt": "Write a function to add two numbers.\n\ndef add_two(a, b):", "func_prompt": "Write a function to add two numbers.\n\ndef add_two(a, b):", "tests": "assert add_two(2, 3) == 5\nassert add_two(10, 5) == 15\nassert add_two(-1, 1) == 0", "setup_code": ""} |
| {"name": "multiply_two", "prompt": "Write a function to multiply two numbers.\n\ndef multiply_two(a, b):", "func_prompt": "Write a function to multiply two numbers.\n\ndef multiply_two(a, b):", "tests": "assert multiply_two(2, 3) == 6\nassert multiply_two(4, 5) == 20\nassert multiply_two(0, 9) == 0", "setup_code": ""} |
| {"name": "square", "prompt": "Write a function to return the square of a number.\n\ndef square(n):", "func_prompt": "Write a function to return the square of a number.\n\ndef square(n):", "tests": "assert square(2) == 4\nassert square(5) == 25\nassert square(0) == 0", "setup_code": ""} |
| {"name": "cube", "prompt": "Write a function to return the cube of a number.\n\ndef cube(n):", "func_prompt": "Write a function to return the cube of a number.\n\ndef cube(n):", "tests": "assert cube(2) == 8\nassert cube(3) == 27\nassert cube(1) == 1", "setup_code": ""} |
| {"name": "is_even", "prompt": "Write a function to check if a number is even.\n\ndef is_even(n):", "func_prompt": "Write a function to check if a number is even.\n\ndef is_even(n):", "tests": "assert is_even(4) == True\nassert is_even(7) == False\nassert is_even(0) == True", "setup_code": ""} |
| {"name": "is_odd", "prompt": "Write a function to check if a number is odd.\n\ndef is_odd(n):", "func_prompt": "Write a function to check if a number is odd.\n\ndef is_odd(n):", "tests": "assert is_odd(3) == True\nassert is_odd(8) == False\nassert is_odd(1) == True", "setup_code": ""} |
| {"name": "absolute", "prompt": "Write a function to return the absolute value of a number.\n\ndef absolute(n):", "func_prompt": "Write a function to return the absolute value of a number.\n\ndef absolute(n):", "tests": "assert absolute(-5) == 5\nassert absolute(5) == 5\nassert absolute(0) == 0", "setup_code": ""} |
| {"name": "max_two", "prompt": "Write a function to return the larger of two numbers.\n\ndef max_two(a, b):", "func_prompt": "Write a function to return the larger of two numbers.\n\ndef max_two(a, b):", "tests": "assert max_two(3, 5) == 5\nassert max_two(9, 2) == 9\nassert max_two(4, 4) == 4", "setup_code": ""} |
| {"name": "min_two", "prompt": "Write a function to return the smaller of two numbers.\n\ndef min_two(a, b):", "func_prompt": "Write a function to return the smaller of two numbers.\n\ndef min_two(a, b):", "tests": "assert min_two(3, 5) == 3\nassert min_two(9, 2) == 2\nassert min_two(4, 4) == 4", "setup_code": ""} |
| {"name": "factorial", "prompt": "Write a function to compute the factorial of a non-negative integer.\n\ndef factorial(n):", "func_prompt": "Write a function to compute the factorial of a non-negative integer.\n\ndef factorial(n):", "tests": "assert factorial(0) == 1\nassert factorial(4) == 24\nassert factorial(6) == 720", "setup_code": ""} |
| {"name": "is_positive", "prompt": "Write a function to check if a number is positive.\n\ndef is_positive(n):", "func_prompt": "Write a function to check if a number is positive.\n\ndef is_positive(n):", "tests": "assert is_positive(5) == True\nassert is_positive(-3) == False\nassert is_positive(0) == False", "setup_code": ""} |
| {"name": "double", "prompt": "Write a function to return double a number.\n\ndef double(n):", "func_prompt": "Write a function to return double a number.\n\ndef double(n):", "tests": "assert double(3) == 6\nassert double(10) == 20\nassert double(0) == 0", "setup_code": ""} |
| {"name": "half", "prompt": "Write a function to return half of a number using integer division.\n\ndef half(n):", "func_prompt": "Write a function to return half of a number using integer division.\n\ndef half(n):", "tests": "assert half(10) == 5\nassert half(7) == 3\nassert half(0) == 0", "setup_code": ""} |
| {"name": "sign", "prompt": "Write a function that returns 1 if the number is positive, -1 if negative, 0 if zero.\n\ndef sign(n):", "func_prompt": "Write a function that returns 1 if the number is positive, -1 if negative, 0 if zero.\n\ndef sign(n):", "tests": "assert sign(5) == 1\nassert sign(-2) == -1\nassert sign(0) == 0", "setup_code": ""} |
| {"name": "power", "prompt": "Write a function to raise a to the power b.\n\ndef power(a, b):", "func_prompt": "Write a function to raise a to the power b.\n\ndef power(a, b):", "tests": "assert power(2, 3) == 8\nassert power(5, 2) == 25\nassert power(3, 0) == 1", "setup_code": ""} |
| {"name": "mod", "prompt": "Write a function to return a modulo b.\n\ndef mod(a, b):", "func_prompt": "Write a function to return a modulo b.\n\ndef mod(a, b):", "tests": "assert mod(10, 3) == 1\nassert mod(9, 4) == 1\nassert mod(8, 2) == 0", "setup_code": ""} |
| {"name": "is_multiple", "prompt": "Write a function to check if a is a multiple of b.\n\ndef is_multiple(a, b):", "func_prompt": "Write a function to check if a is a multiple of b.\n\ndef is_multiple(a, b):", "tests": "assert is_multiple(10, 5) == True\nassert is_multiple(9, 4) == False\nassert is_multiple(12, 3) == True", "setup_code": ""} |
| {"name": "digit_count", "prompt": "Write a function to count the number of digits in a positive integer.\n\ndef digit_count(n):", "func_prompt": "Write a function to count the number of digits in a positive integer.\n\ndef digit_count(n):", "tests": "assert digit_count(5) == 1\nassert digit_count(123) == 3\nassert digit_count(99999) == 5", "setup_code": ""} |
| {"name": "sum_to_n", "prompt": "Write a function to return the sum of all integers from 1 to n.\n\ndef sum_to_n(n):", "func_prompt": "Write a function to return the sum of all integers from 1 to n.\n\ndef sum_to_n(n):", "tests": "assert sum_to_n(5) == 15\nassert sum_to_n(10) == 55\nassert sum_to_n(1) == 1", "setup_code": ""} |
| {"name": "sum_list", "prompt": "Write a function to return the sum of a list of numbers.\n\ndef sum_list(nums):", "func_prompt": "Write a function to return the sum of a list of numbers.\n\ndef sum_list(nums):", "tests": "assert sum_list([1, 2, 3]) == 6\nassert sum_list([10, 20]) == 30\nassert sum_list([-1, 1, 5]) == 5", "setup_code": ""} |
| {"name": "max_list", "prompt": "Write a function to return the largest number in a list.\n\ndef max_list(nums):", "func_prompt": "Write a function to return the largest number in a list.\n\ndef max_list(nums):", "tests": "assert max_list([1, 5, 3]) == 5\nassert max_list([9, 2, 7]) == 9\nassert max_list([4]) == 4", "setup_code": ""} |
| {"name": "min_list", "prompt": "Write a function to return the smallest number in a list.\n\ndef min_list(nums):", "func_prompt": "Write a function to return the smallest number in a list.\n\ndef min_list(nums):", "tests": "assert min_list([1, 5, 3]) == 1\nassert min_list([9, 2, 7]) == 2\nassert min_list([4]) == 4", "setup_code": ""} |
| {"name": "length_list", "prompt": "Write a function to return the number of elements in a list.\n\ndef length_list(lst):", "func_prompt": "Write a function to return the number of elements in a list.\n\ndef length_list(lst):", "tests": "assert length_list([1, 2, 3]) == 3\nassert length_list([]) == 0\nassert length_list([5, 5, 5, 5]) == 4", "setup_code": ""} |
| {"name": "average", "prompt": "Write a function to return the average of a list of numbers.\n\ndef average(nums):", "func_prompt": "Write a function to return the average of a list of numbers.\n\ndef average(nums):", "tests": "assert average([2, 4]) == 3.0\nassert average([1, 2, 3]) == 2.0\nassert average([10]) == 10.0", "setup_code": ""} |
| {"name": "count_positives", "prompt": "Write a function to count the positive numbers in a list.\n\ndef count_positives(nums):", "func_prompt": "Write a function to count the positive numbers in a list.\n\ndef count_positives(nums):", "tests": "assert count_positives([1, -2, 3]) == 2\nassert count_positives([-1, -2]) == 0\nassert count_positives([5, 5]) == 2", "setup_code": ""} |
| {"name": "sum_even", "prompt": "Write a function to return the sum of the even numbers in a list.\n\ndef sum_even(nums):", "func_prompt": "Write a function to return the sum of the even numbers in a list.\n\ndef sum_even(nums):", "tests": "assert sum_even([1, 2, 3, 4]) == 6\nassert sum_even([2, 4, 6]) == 12\nassert sum_even([1, 3]) == 0", "setup_code": ""} |
| {"name": "filter_even", "prompt": "Write a function to return a list of the even numbers from the input list.\n\ndef filter_even(nums):", "func_prompt": "Write a function to return a list of the even numbers from the input list.\n\ndef filter_even(nums):", "tests": "assert filter_even([1, 2, 3, 4]) == [2, 4]\nassert filter_even([5, 6, 7]) == [6]\nassert filter_even([2]) == [2]", "setup_code": ""} |
| {"name": "filter_odd", "prompt": "Write a function to return a list of the odd numbers from the input list.\n\ndef filter_odd(nums):", "func_prompt": "Write a function to return a list of the odd numbers from the input list.\n\ndef filter_odd(nums):", "tests": "assert filter_odd([1, 2, 3, 4]) == [1, 3]\nassert filter_odd([5, 6, 7]) == [5, 7]\nassert filter_odd([2]) == []", "setup_code": ""} |
| {"name": "reverse_list", "prompt": "Write a function to return the list reversed.\n\ndef reverse_list(lst):", "func_prompt": "Write a function to return the list reversed.\n\ndef reverse_list(lst):", "tests": "assert reverse_list([1, 2, 3]) == [3, 2, 1]\nassert reverse_list([9]) == [9]\nassert reverse_list([4, 5]) == [5, 4]", "setup_code": ""} |
| {"name": "unique_list", "prompt": "Write a function to return the sorted list of unique elements.\n\ndef unique_list(lst):", "func_prompt": "Write a function to return the sorted list of unique elements.\n\ndef unique_list(lst):", "tests": "assert unique_list([1, 2, 2, 3]) == [1, 2, 3]\nassert unique_list([5, 5, 5]) == [5]\nassert unique_list([3, 1, 2]) == [1, 2, 3]", "setup_code": ""} |
| {"name": "count_element", "prompt": "Write a function to count how many times x appears in a list.\n\ndef count_element(lst, x):", "func_prompt": "Write a function to count how many times x appears in a list.\n\ndef count_element(lst, x):", "tests": "assert count_element([1, 2, 2, 3], 2) == 2\nassert count_element([5, 5, 5], 5) == 3\nassert count_element([1, 2], 9) == 0", "setup_code": ""} |
| {"name": "contains", "prompt": "Write a function to check if x is in the list.\n\ndef contains(lst, x):", "func_prompt": "Write a function to check if x is in the list.\n\ndef contains(lst, x):", "tests": "assert contains([1, 2, 3], 2) == True\nassert contains([5, 6], 9) == False\nassert contains([], 1) == False", "setup_code": ""} |
| {"name": "first_element", "prompt": "Write a function to return the first element of a list.\n\ndef first_element(lst):", "func_prompt": "Write a function to return the first element of a list.\n\ndef first_element(lst):", "tests": "assert first_element([1, 2, 3]) == 1\nassert first_element([9, 8]) == 9\nassert first_element([5]) == 5", "setup_code": ""} |
| {"name": "last_element", "prompt": "Write a function to return the last element of a list.\n\ndef last_element(lst):", "func_prompt": "Write a function to return the last element of a list.\n\ndef last_element(lst):", "tests": "assert last_element([1, 2, 3]) == 3\nassert last_element([9, 8]) == 8\nassert last_element([5]) == 5", "setup_code": ""} |
| {"name": "product_list", "prompt": "Write a function to return the product of all numbers in a list.\n\ndef product_list(nums):", "func_prompt": "Write a function to return the product of all numbers in a list.\n\ndef product_list(nums):", "tests": "assert product_list([1, 2, 3]) == 6\nassert product_list([4, 5]) == 20\nassert product_list([2, 2, 2]) == 8", "setup_code": ""} |
| {"name": "max_minus_min", "prompt": "Write a function to return the difference between the largest and smallest element.\n\ndef max_minus_min(nums):", "func_prompt": "Write a function to return the difference between the largest and smallest element.\n\ndef max_minus_min(nums):", "tests": "assert max_minus_min([1, 5, 3]) == 4\nassert max_minus_min([9, 2]) == 7\nassert max_minus_min([4, 4]) == 0", "setup_code": ""} |
| {"name": "count_greater", "prompt": "Write a function to count elements greater than k.\n\ndef count_greater(nums, k):", "func_prompt": "Write a function to count elements greater than k.\n\ndef count_greater(nums, k):", "tests": "assert count_greater([1, 5, 3], 2) == 2\nassert count_greater([9, 2], 5) == 1\nassert count_greater([1, 2], 9) == 0", "setup_code": ""} |
| {"name": "double_all", "prompt": "Write a function to return a list with every element doubled.\n\ndef double_all(nums):", "func_prompt": "Write a function to return a list with every element doubled.\n\ndef double_all(nums):", "tests": "assert double_all([1, 2, 3]) == [2, 4, 6]\nassert double_all([5]) == [10]\nassert double_all([0, 4]) == [0, 8]", "setup_code": ""} |
| {"name": "add_to_all", "prompt": "Write a function to add k to every element of a list.\n\ndef add_to_all(nums, k):", "func_prompt": "Write a function to add k to every element of a list.\n\ndef add_to_all(nums, k):", "tests": "assert add_to_all([1, 2, 3], 10) == [11, 12, 13]\nassert add_to_all([5], 1) == [6]\nassert add_to_all([0], 0) == [0]", "setup_code": ""} |
| {"name": "sort_list", "prompt": "Write a function to return the list sorted in ascending order.\n\ndef sort_list(lst):", "func_prompt": "Write a function to return the list sorted in ascending order.\n\ndef sort_list(lst):", "tests": "assert sort_list([3, 1, 2]) == [1, 2, 3]\nassert sort_list([9, 5, 7]) == [5, 7, 9]\nassert sort_list([1]) == [1]", "setup_code": ""} |
| {"name": "sort_desc", "prompt": "Write a function to return the list sorted in descending order.\n\ndef sort_desc(lst):", "func_prompt": "Write a function to return the list sorted in descending order.\n\ndef sort_desc(lst):", "tests": "assert sort_desc([3, 1, 2]) == [3, 2, 1]\nassert sort_desc([9, 5, 7]) == [9, 7, 5]\nassert sort_desc([1]) == [1]", "setup_code": ""} |
| {"name": "second_largest", "prompt": "Write a function to return the second largest element in a list.\n\ndef second_largest(nums):", "func_prompt": "Write a function to return the second largest element in a list.\n\ndef second_largest(nums):", "tests": "assert second_largest([1, 5, 3]) == 3\nassert second_largest([9, 2, 7]) == 7\nassert second_largest([4, 4, 5]) == 4", "setup_code": ""} |
| {"name": "reverse_string", "prompt": "Write a function to reverse a string.\n\ndef reverse_string(s):", "func_prompt": "Write a function to reverse a string.\n\ndef reverse_string(s):", "tests": "assert reverse_string('hello') == 'olleh'\nassert reverse_string('abc') == 'cba'\nassert reverse_string('x') == 'x'", "setup_code": ""} |
| {"name": "string_length", "prompt": "Write a function to return the length of a string.\n\ndef string_length(s):", "func_prompt": "Write a function to return the length of a string.\n\ndef string_length(s):", "tests": "assert string_length('hello') == 5\nassert string_length('') == 0\nassert string_length('ab') == 2", "setup_code": ""} |
| {"name": "to_upper", "prompt": "Write a function to convert a string to uppercase.\n\ndef to_upper(s):", "func_prompt": "Write a function to convert a string to uppercase.\n\ndef to_upper(s):", "tests": "assert to_upper('hello') == 'HELLO'\nassert to_upper('Abc') == 'ABC'\nassert to_upper('x') == 'X'", "setup_code": ""} |
| {"name": "to_lower", "prompt": "Write a function to convert a string to lowercase.\n\ndef to_lower(s):", "func_prompt": "Write a function to convert a string to lowercase.\n\ndef to_lower(s):", "tests": "assert to_lower('HELLO') == 'hello'\nassert to_lower('Abc') == 'abc'\nassert to_lower('X') == 'x'", "setup_code": ""} |
| {"name": "first_char", "prompt": "Write a function to return the first character of a string.\n\ndef first_char(s):", "func_prompt": "Write a function to return the first character of a string.\n\ndef first_char(s):", "tests": "assert first_char('hello') == 'h'\nassert first_char('abc') == 'a'\nassert first_char('x') == 'x'", "setup_code": ""} |
| {"name": "last_char", "prompt": "Write a function to return the last character of a string.\n\ndef last_char(s):", "func_prompt": "Write a function to return the last character of a string.\n\ndef last_char(s):", "tests": "assert last_char('hello') == 'o'\nassert last_char('abc') == 'c'\nassert last_char('x') == 'x'", "setup_code": ""} |
| {"name": "count_char", "prompt": "Write a function to count how many times character c appears in string s.\n\ndef count_char(s, c):", "func_prompt": "Write a function to count how many times character c appears in string s.\n\ndef count_char(s, c):", "tests": "assert count_char('banana', 'a') == 3\nassert count_char('hello', 'l') == 2\nassert count_char('abc', 'z') == 0", "setup_code": ""} |
| {"name": "is_palindrome", "prompt": "Write a function to check if a string is a palindrome.\n\ndef is_palindrome(s):", "func_prompt": "Write a function to check if a string is a palindrome.\n\ndef is_palindrome(s):", "tests": "assert is_palindrome('racecar') == True\nassert is_palindrome('hello') == False\nassert is_palindrome('aba') == True", "setup_code": ""} |
| {"name": "count_vowels", "prompt": "Write a function to count the vowels in a string.\n\ndef count_vowels(s):", "func_prompt": "Write a function to count the vowels in a string.\n\ndef count_vowels(s):", "tests": "assert count_vowels('hello') == 2\nassert count_vowels('sky') == 0\nassert count_vowels('aeiou') == 5", "setup_code": ""} |
| {"name": "repeat_string", "prompt": "Write a function to repeat a string n times.\n\ndef repeat_string(s, n):", "func_prompt": "Write a function to repeat a string n times.\n\ndef repeat_string(s, n):", "tests": "assert repeat_string('ab', 3) == 'ababab'\nassert repeat_string('x', 5) == 'xxxxx'\nassert repeat_string('hi', 1) == 'hi'", "setup_code": ""} |
| {"name": "capitalize_first", "prompt": "Write a function to capitalize the first letter of a string.\n\ndef capitalize_first(s):", "func_prompt": "Write a function to capitalize the first letter of a string.\n\ndef capitalize_first(s):", "tests": "assert capitalize_first('hello') == 'Hello'\nassert capitalize_first('world') == 'World'\nassert capitalize_first('a') == 'A'", "setup_code": ""} |
| {"name": "count_words", "prompt": "Write a function to count the number of words in a sentence.\n\ndef count_words(s):", "func_prompt": "Write a function to count the number of words in a sentence.\n\ndef count_words(s):", "tests": "assert count_words('hello world') == 2\nassert count_words('one') == 1\nassert count_words('a b c d') == 4", "setup_code": ""} |
| {"name": "remove_spaces", "prompt": "Write a function to remove all spaces from a string.\n\ndef remove_spaces(s):", "func_prompt": "Write a function to remove all spaces from a string.\n\ndef remove_spaces(s):", "tests": "assert remove_spaces('a b c') == 'abc'\nassert remove_spaces('hello world') == 'helloworld'\nassert remove_spaces('x') == 'x'", "setup_code": ""} |
| {"name": "starts_with", "prompt": "Write a function to check if string s starts with prefix p.\n\ndef starts_with(s, p):", "func_prompt": "Write a function to check if string s starts with prefix p.\n\ndef starts_with(s, p):", "tests": "assert starts_with('hello', 'he') == True\nassert starts_with('world', 'wo') == True\nassert starts_with('abc', 'z') == False", "setup_code": ""} |
| {"name": "ends_with", "prompt": "Write a function to check if string s ends with suffix p.\n\ndef ends_with(s, p):", "func_prompt": "Write a function to check if string s ends with suffix p.\n\ndef ends_with(s, p):", "tests": "assert ends_with('hello', 'lo') == True\nassert ends_with('world', 'ld') == True\nassert ends_with('abc', 'z') == False", "setup_code": ""} |
| {"name": "concat", "prompt": "Write a function to concatenate two strings.\n\ndef concat(a, b):", "func_prompt": "Write a function to concatenate two strings.\n\ndef concat(a, b):", "tests": "assert concat('foo', 'bar') == 'foobar'\nassert concat('a', 'b') == 'ab'\nassert concat('hi', '') == 'hi'", "setup_code": ""} |
| {"name": "is_empty", "prompt": "Write a function to check if a string is empty.\n\ndef is_empty(s):", "func_prompt": "Write a function to check if a string is empty.\n\ndef is_empty(s):", "tests": "assert is_empty('') == True\nassert is_empty('a') == False\nassert is_empty('hello') == False", "setup_code": ""} |
| {"name": "nth_char", "prompt": "Write a function to return the character at index i of string s.\n\ndef nth_char(s, i):", "func_prompt": "Write a function to return the character at index i of string s.\n\ndef nth_char(s, i):", "tests": "assert nth_char('hello', 1) == 'e'\nassert nth_char('world', 0) == 'w'\nassert nth_char('abc', 2) == 'c'", "setup_code": ""} |
| {"name": "swapcase", "prompt": "Write a function to swap the case of every letter in a string.\n\ndef swapcase(s):", "func_prompt": "Write a function to swap the case of every letter in a string.\n\ndef swapcase(s):", "tests": "assert swapcase('Hello') == 'hELLO'\nassert swapcase('aBc') == 'AbC'\nassert swapcase('XyZ') == 'xYz'", "setup_code": ""} |
| {"name": "count_upper", "prompt": "Write a function to count the uppercase letters in a string.\n\ndef count_upper(s):", "func_prompt": "Write a function to count the uppercase letters in a string.\n\ndef count_upper(s):", "tests": "assert count_upper('Hello') == 1\nassert count_upper('ABC') == 3\nassert count_upper('abc') == 0", "setup_code": ""} |
|
|