Dar3devil's picture
sync source for HF Jobs training run
46300b3 verified
Raw
History Blame Contribute Delete
8.52 kB
{"id": "code_001", "type": "code", "split": "train", "question": "Write a Python function `add(a, b)` that returns the sum of two numbers.", "tests": ["assert add(2, 3) == 5", "assert add(-1, 1) == 0", "assert add(0, 0) == 0"]}
{"id": "code_002", "type": "code", "split": "train", "question": "Write a Python function `is_even(n)` that returns True if n is even, False otherwise.", "tests": ["assert is_even(4) is True", "assert is_even(7) is False", "assert is_even(0) is True"]}
{"id": "code_003", "type": "code", "split": "train", "question": "Write a Python function `reverse_string(s)` that returns the reverse of string s.", "tests": ["assert reverse_string('hello') == 'olleh'", "assert reverse_string('') == ''", "assert reverse_string('a') == 'a'"]}
{"id": "code_004", "type": "code", "split": "train", "question": "Write a Python function `factorial(n)` that returns n! for n >= 0.", "tests": ["assert factorial(0) == 1", "assert factorial(5) == 120", "assert factorial(1) == 1"]}
{"id": "code_005", "type": "code", "split": "train", "question": "Write a Python function `count_vowels(s)` that counts vowels (aeiou, case insensitive) in string s.", "tests": ["assert count_vowels('hello') == 2", "assert count_vowels('AEIOU') == 5", "assert count_vowels('xyz') == 0"]}
{"id": "code_006", "type": "code", "split": "train", "question": "Write a Python function `max_in_list(lst)` that returns the largest number in lst.", "tests": ["assert max_in_list([1, 2, 3]) == 3", "assert max_in_list([-5, -1, -10]) == -1", "assert max_in_list([7]) == 7"]}
{"id": "code_007", "type": "code", "split": "train", "question": "Write a Python function `is_palindrome(s)` that returns True if s reads the same forwards and backwards.", "tests": ["assert is_palindrome('racecar') is True", "assert is_palindrome('hello') is False", "assert is_palindrome('') is True"]}
{"id": "code_008", "type": "code", "split": "train", "question": "Write a Python function `fibonacci(n)` that returns the nth Fibonacci number (fib(0)=0, fib(1)=1).", "tests": ["assert fibonacci(0) == 0", "assert fibonacci(1) == 1", "assert fibonacci(7) == 13"]}
{"id": "code_009", "type": "code", "split": "train", "question": "Write a Python function `unique(lst)` that returns a list of unique elements preserving order.", "tests": ["assert unique([1, 2, 2, 3, 1]) == [1, 2, 3]", "assert unique([]) == []", "assert unique(['a', 'a', 'b']) == ['a', 'b']"]}
{"id": "code_010", "type": "code", "split": "train", "question": "Write a Python function `sum_digits(n)` that sums the digits of non-negative integer n.", "tests": ["assert sum_digits(123) == 6", "assert sum_digits(0) == 0", "assert sum_digits(9999) == 36"]}
{"id": "code_011", "type": "code", "split": "train", "question": "Write a Python function `gcd(a, b)` that returns the greatest common divisor.", "tests": ["assert gcd(12, 18) == 6", "assert gcd(7, 13) == 1", "assert gcd(100, 25) == 25"]}
{"id": "code_012", "type": "code", "split": "train", "question": "Write a Python function `flatten(lst)` that flattens a list of lists by one level.", "tests": ["assert flatten([[1,2],[3,4]]) == [1,2,3,4]", "assert flatten([]) == []", "assert flatten([[1],[2,3],[]]) == [1,2,3]"]}
{"id": "code_013", "type": "code", "split": "train", "question": "Write a Python function `is_prime(n)` that returns True if n is a prime > 1.", "tests": ["assert is_prime(2) is True", "assert is_prime(15) is False", "assert is_prime(17) is True", "assert is_prime(1) is False"]}
{"id": "code_014", "type": "code", "split": "train", "question": "Write a Python function `word_count(s)` that returns the number of whitespace-separated words.", "tests": ["assert word_count('hello world') == 2", "assert word_count('') == 0", "assert word_count(' one two three ') == 3"]}
{"id": "code_015", "type": "code", "split": "train", "question": "Write a Python function `second_largest(lst)` that returns the second largest distinct number.", "tests": ["assert second_largest([1, 2, 3, 4]) == 3", "assert second_largest([5, 5, 4]) == 4", "assert second_largest([10, 20]) == 10"]}
{"id": "code_016", "type": "code", "split": "train", "question": "Write a Python function `caesar(s, k)` that shifts each letter by k positions, preserving case; non-letters unchanged.", "tests": ["assert caesar('abc', 1) == 'bcd'", "assert caesar('XYZ', 3) == 'ABC'", "assert caesar('Hello, World!', 13) == 'Uryyb, Jbeyq!'"]}
{"id": "code_017", "type": "code", "split": "train", "question": "Write a Python function `merge_sorted(a, b)` that merges two sorted lists into one sorted list.", "tests": ["assert merge_sorted([1,3,5],[2,4,6]) == [1,2,3,4,5,6]", "assert merge_sorted([],[1,2]) == [1,2]", "assert merge_sorted([1,1],[1,1]) == [1,1,1,1]"]}
{"id": "code_018", "type": "code", "split": "train", "question": "Write a Python function `most_common(lst)` that returns the most frequent element (any if tied).", "tests": ["assert most_common([1,2,2,3]) == 2", "assert most_common(['a','b','a']) == 'a'", "assert most_common([5]) == 5"]}
{"id": "code_019", "type": "code", "split": "train", "question": "Write a Python function `chunks(lst, n)` that splits lst into chunks of size n.", "tests": ["assert chunks([1,2,3,4,5], 2) == [[1,2],[3,4],[5]]", "assert chunks([], 3) == []", "assert chunks([1,2,3], 1) == [[1],[2],[3]]"]}
{"id": "code_020", "type": "code", "split": "train", "question": "Write a Python function `roman(n)` that converts integer 1-3999 to Roman numerals.", "tests": ["assert roman(1) == 'I'", "assert roman(4) == 'IV'", "assert roman(1994) == 'MCMXCIV'"]}
{"id": "code_t01", "type": "code", "split": "test", "question": "Write a Python function `square(x)` that returns x squared.", "tests": ["assert square(3) == 9", "assert square(-4) == 16", "assert square(0) == 0"]}
{"id": "code_t02", "type": "code", "split": "test", "question": "Write a Python function `is_anagram(a, b)` that checks if two strings are anagrams (case-insensitive, ignoring spaces).", "tests": ["assert is_anagram('listen', 'silent') is True", "assert is_anagram('Hello', 'World') is False", "assert is_anagram('a gentleman', 'elegant man') is True"]}
{"id": "code_t03", "type": "code", "split": "test", "question": "Write a Python function `count_words(s)` that returns a dict mapping each word to its count (whitespace-separated, lowercase).", "tests": ["assert count_words('a a b') == {'a': 2, 'b': 1}", "assert count_words('') == {}", "assert count_words('Hi hi HI') == {'hi': 3}"]}
{"id": "code_t04", "type": "code", "split": "test", "question": "Write a Python function `power(b, e)` that computes b**e for non-negative integer e using a loop (no ** operator).", "tests": ["assert power(2, 10) == 1024", "assert power(5, 0) == 1", "assert power(3, 3) == 27"]}
{"id": "code_t05", "type": "code", "split": "test", "question": "Write a Python function `compress(s)` that returns 'a3b2c1' style run-length encoding.", "tests": ["assert compress('aaabbc') == 'a3b2c1'", "assert compress('abc') == 'a1b1c1'", "assert compress('') == ''"]}
{"id": "code_t06", "type": "code", "split": "test", "question": "Write a Python function `balanced(s)` that returns True if all (), [], {} pairs are balanced and properly nested.", "tests": ["assert balanced('()[]{}') is True", "assert balanced('([)]') is False", "assert balanced('') is True"]}
{"id": "code_t07", "type": "code", "split": "test", "question": "Write a Python function `lcm(a, b)` that returns the least common multiple of two positive integers.", "tests": ["assert lcm(4, 6) == 12", "assert lcm(7, 13) == 91", "assert lcm(1, 5) == 5"]}
{"id": "code_t08", "type": "code", "split": "test", "question": "Write a Python function `rotate(lst, k)` that rotates list right by k positions.", "tests": ["assert rotate([1,2,3,4], 1) == [4,1,2,3]", "assert rotate([1,2,3], 0) == [1,2,3]", "assert rotate([1,2,3], 4) == [3,1,2]"]}
{"id": "code_t09", "type": "code", "split": "test", "question": "Write a Python function `digit_sum_seq(n)` that repeatedly sums digits until single digit (digital root).", "tests": ["assert digit_sum_seq(38) == 2", "assert digit_sum_seq(0) == 0", "assert digit_sum_seq(123456) == 3"]}
{"id": "code_t10", "type": "code", "split": "test", "question": "Write a Python function `pairs_summing_to(lst, target)` that returns list of unique sorted tuples (a,b) with a+b==target, a<=b.", "tests": ["assert pairs_summing_to([1,2,3,4], 5) == [(1,4),(2,3)]", "assert pairs_summing_to([2,2,3], 4) == [(2,2)]", "assert pairs_summing_to([1,2], 10) == []"]}