task_id stringlengths 11 13 | spec_type stringclasses 1
value | ambiguous_prompt stringlengths 57 214 | gold_prompt stringlengths 119 331 | constraints listlengths 2 4 | stated_test_ids listlengths 1 1 | hidden_test_ids listlengths 1 3 |
|---|---|---|---|---|---|---|
HumanEval/26 | algorithm | Write a function named `solution` that takes a list of integers and removes any elements that appear more than once. | Write a function named `solution` that takes a list of integers, removes all elements that occur more than once, preserves the original order of remaining elements, and returns a new list without mutating the input. | [
{
"id": "C1",
"description": "Elements appearing more than once are removed",
"test_code": "result = solution([1, 2, 3, 2, 4])\nassert 2 not in result, f'Duplicate element 2 should be removed, got {result}'"
},
{
"id": "C2",
"description": "Original order of remaining elements is preserved",... | [
"C1"
] | [
"C2",
"C3",
"C4"
] |
HumanEval/18 | algorithm | Write a function named `solution` that counts how many times a given substring appears in a string. | Write a function named `solution` that counts how many times a given substring appears in a string, including overlapping occurrences. | [
{
"id": "C1",
"description": "Basic substring count works",
"test_code": "result = solution('abc', 'a')\nassert result == 1, f'Expected 1, got {result}'"
},
{
"id": "C2",
"description": "Overlapping occurrences are counted",
"test_code": "result = solution('aaaa', 'aa')\nassert result ==... | [
"C1"
] | [
"C2",
"C3"
] |
HumanEval/25 | algorithm | Write a function named `solution` that returns the prime factors of a given integer. | Write a function named `solution` that returns a list of prime factors of the given integer in ascending order. Each factor should appear as many times as it appears in the factorization. The product of all returned factors should equal the input. | [
{
"id": "C1",
"description": "Basic factorization works",
"test_code": "result = solution(13)\nassert result == [13], f'Expected [13], got {result}'"
},
{
"id": "C2",
"description": "Output is in ascending order",
"test_code": "result = solution(15)\nassert result == [3, 5], f'Expected [... | [
"C1"
] | [
"C2",
"C3",
"C4"
] |
HumanEval/12 | algorithm | Write a function named `solution` that takes a list of strings and returns the longest one. | Write a function named `solution` that takes a list of strings and returns the longest one. If multiple strings share the same maximum length, return the first one. Return None if the input list is empty. | [
{
"id": "C1",
"description": "Returns the longest string",
"test_code": "result = solution(['a', 'ab', 'abc'])\nassert result == 'abc', f'Expected abc, got {result}'"
},
{
"id": "C2",
"description": "Returns first string when tie exists",
"test_code": "result = solution(['bc', 'ab', 'cd'... | [
"C1"
] | [
"C2",
"C3"
] |
HumanEval/20 | algorithm | Write a function named `solution` that takes a list of numbers and returns the two that are closest to each other. | Write a function named `solution` that takes a list of numbers of length at least two, finds the two closest to each other, and returns them as a tuple in ascending order (smaller number first). | [
{
"id": "C1",
"description": "Identifies closest pair correctly",
"test_code": "result = solution([1.0, 1.5, 2.0, 3.0, 4.0])\nassert tuple(result) == (1.0, 1.5), f'Expected (1.0, 1.5), got {result}'"
},
{
"id": "C2",
"description": "Returns pair in ascending order (smaller first), input give... | [
"C1"
] | [
"C2",
"C3"
] |
HumanEval/21 | algorithm | Write a function named `solution` that takes a list of numbers and applies a linear transformation to it. | Write a function named `solution` that takes a list of numbers (at least two elements), and applies a linear transformation so that the smallest number becomes 0 and the largest becomes 1. Preserve the original order of elements. | [
{
"id": "C1",
"description": "Basic linear transformation works",
"test_code": "result = solution([1.0, 2.0, 3.0, 4.0, 5.0])\nassert result == [0.0, 0.25, 0.5, 0.75, 1.0], f'Expected [0.0, 0.25, 0.5, 0.75, 1.0], got {result}'"
},
{
"id": "C2",
"description": "Minimum becomes exactly 0 and ma... | [
"C1"
] | [
"C2",
"C3"
] |
HumanEval/7 | algorithm | Write a function named `solution` that takes a list of strings and a substring, and returns only the strings that contain the substring. | Write a function named `solution` that takes a list of strings and a substring, and returns only the strings that contain the substring. Matching is case sensitive. Preserve the original order of matching strings. Return an empty list if no strings match or if the input list is empty. | [
{
"id": "C1",
"description": "Basic filtering works",
"test_code": "result = solution(['apple', 'banana', 'apricot'], 'ap')\nassert result == ['apple', 'apricot'], f'Expected [apple, apricot], got {result}'"
},
{
"id": "C2",
"description": "Matching is case sensitive",
"test_code": "resu... | [
"C1"
] | [
"C2",
"C3",
"C4"
] |
HumanEval/47 | algorithm | Write a function named `solution` that returns the median | Write a function named `solution` that takes a list l and returns the median of its elements. For odd-length lists return the middle element. For even-length lists return the average of the two middle elements. Do not mutate the input list. | [
{
"id": "C1",
"description": "Basic median calculation",
"test_code": "result = solution([2, 4, 6])\nassert result == 4, f'Expected 4, got {result}'"
},
{
"id": "C2",
"description": "Handles negative numbers correctly",
"test_code": "result = solution([-100, 0, 5, 15, 20])\nassert result... | [
"C1"
] | [
"C2",
"C3",
"C4"
] |
HumanEval/30 | algorithm | Write a function named `solution` that takes a list of numbers and returns only the positive ones. | Write a function named `solution` that takes a list of numbers and returns only the strictly positive values (greater than zero). Preserve the original order of elements. Do not mutate the input list. Return an empty list if no positive values exist. | [
{
"id": "C1",
"description": "Basic positive filtering works",
"test_code": "result = solution([-2, 4, 6])\nassert result == [4, 6], f'Expected [4, 6], got {result}'"
},
{
"id": "C2",
"description": "Zero is excluded (strictly greater than zero)",
"test_code": "result = solution([-2, 0, ... | [
"C1"
] | [
"C2",
"C3",
"C4"
] |
HumanEval/34 | algorithm | Write a function named solution that returns the unique elements in a list. | Write a function named `solution` that takes a list and returns only the unique values, sorted in ascending order. There should be no duplicate values. | [
{
"id": "C1",
"description": "Only unique values",
"test_code": "result = solution([-2, 4, 4, 6, 6])\nassert result == [-2, 4, 6], f'Expected [-2, 4, 6], got {result}'"
},
{
"id": "C2",
"description": "Sorted in ascending order",
"test_code": "result = solution([-2, 0, 5, 3, 5, 0, 3])\na... | [
"C1"
] | [
"C2"
] |
HumanEval/51 | algorithm | Write a function named `solution` that returns a string without vowels. | Write a function named `solution` that takes a string and returns the same string with all vowels (both uppercase and lowercase) removed. Preserve the original order and case of remaining characters. Return the string unchanged if it has no vowels. Return an empty string if given an empty string. | [
{
"id": "C1",
"description": "Removes lowercase vowels",
"test_code": "result = solution('testing')\nassert result == 'tstng', f\"Expected tstng, got {result}\""
},
{
"id": "C2",
"description": "Removes uppercase vowels too",
"test_code": "result = solution('TEstIng')\nassert result == '... | [
"C1"
] | [
"C2",
"C3",
"C4"
] |
HumanEval/57 | algorithm | Write a function named `solution` that returns True if a list is monotonically increasing. | Write a function named `solution` that returns True if the elements are monotonically increasing or monotonically decreasing (the element following is always equal to or less/greater than). Otherwise, it will return False. The list does not mutate. | [
{
"id": "C1",
"description": "Monotonically increasing",
"test_code": "result = solution([1, 2, 3, 4])\nassert result == True, f\"Expected True, got {result}\""
},
{
"id": "C2",
"description": "Monotonically decreasing",
"test_code": "result = solution([4, 3, 2, 1])\nassert result == Tru... | [
"C1"
] | [
"C2",
"C3"
] |
HumanEval/58 | algorithm | Write a function named `solution` that returns common elements between 2 lists. | Write a function named `solution` that a list of unique and common elements between 2 lists, sorted in ascending order. | [
{
"id": "C1",
"description": "Captures common elements",
"test_code": "result = solution([1, 2, 3, 4], [2, 3])\nassert result == [2, 3], f\"Expected [2, 3], got {result}\""
},
{
"id": "C2",
"description": "Only returns unique elements, no duplicates even if input has repeats",
"test_code... | [
"C1"
] | [
"C2",
"C3"
] |
HumanEval/42 | algorithm | Write a function named `solution` that returns a list incremented by 1. | Write a function named `solution` that takes a list of numbers and returns a new list with each element incremented by 1. Preserve the original order. Do not mutate the input list. | [
{
"id": "C1",
"description": "Increments elements",
"test_code": "result = solution([1, 2, 3])\nassert result == [2, 3, 4], f'Expected [2, 3, 4], got {result}'"
},
{
"id": "C2",
"description": "Ordering is maintained",
"test_code": "result = solution([-1, -2, 1, 5, 10])\nassert result ==... | [
"C1"
] | [
"C2",
"C3"
] |
HumanEval/65 | algorithm | Write a function named `solution` that takes an integer x and a shift amount, and circularly shifts the digits of x to the right by shift positions, returning the result as a string. | Write a function named `solution` that takes an integer x and a shift amount. Circularly shift the digits of x to the right by shift positions and return the result as a string. If shift is greater than the number of digits in x, return the digits reversed instead. | [
{
"id": "C1",
"description": "Basic circular shift works",
"test_code": "result = solution(12, 1)\nassert result == '21', f\"Expected '21', got {result}\""
},
{
"id": "C2",
"description": "Shift equal to digit length wraps back to original",
"test_code": "result = solution(12, 2)\nassert... | [
"C1"
] | [
"C2",
"C3"
] |
HumanEval/68 | algorithm | Write a function named `solution` that takes a list of non-negative integers and returns the smallest even value along with its index, as a list `[value, index]`. | Write a function named `solution` that takes a list of non-negative integers and returns the smallest even value along with its index, as a list `[value, index]`. If multiple positions share the smallest even value, return the one with the smallest index. If no even values exist or the input list is empty, return an em... | [
{
"id": "C1",
"description": "Basic smallest even value with index works",
"test_code": "result = solution([4, 2, 3])\nassert result == [2, 1], f\"Expected [2, 1], got {result}\""
},
{
"id": "C2",
"description": "Tie-breaking returns smallest index among equal smallest even values",
"tes... | [
"C1"
] | [
"C2",
"C3",
"C4"
] |
HumanEval/70 | algorithm | Write a function named `solution` that takes a list of integers, and returns the list in a strange order: minimum first, then maximum of the remaining, then minimum of the remaining, and so on. | Write a function named `solution` that takes a list of integers and returns them reordered by repeatedly taking the minimum then the maximum of the remaining elements until all elements are placed. Handle duplicate values, odd-length lists, and empty input correctly. | [
{
"id": "C1",
"description": "Basic strange sort works",
"test_code": "result = solution([1, 2, 3, 4])\nassert result == [1, 4, 2, 3], f\"Expected [1, 4, 2, 3], got {result}\""
},
{
"id": "C2",
"description": "Handles duplicate values correctly",
"test_code": "result = solution([5, 5, 5,... | [
"C1"
] | [
"C2",
"C3",
"C4"
] |
HumanEval/72 | algorithm | Write a function named `solution` that takes a list q and a weight limit w, and returns True if the sum of q's elements is less than or equal to w. | Write a function named `solution` that takes a list q and a weight limit w. Return True only if q is a palindrome (reads the same forwards and backwards) AND the sum of its elements is less than or equal to w. Return False if either condition fails. | [
{
"id": "C1",
"description": "Basic weight check works",
"test_code": "result = solution([3], 5)\nassert result == True, f\"Expected True, got {result}\""
},
{
"id": "C2",
"description": "Returns False when weight is fine but list is not a palindrome",
"test_code": "result = solution([1,... | [
"C1"
] | [
"C2",
"C3",
"C4"
] |
HumanEval/74 | algorithm | Write a function named `solution` that takes two lists of strings and returns whichever list has fewer total characters across all its strings. | Write a function named `solution` that takes two lists of strings, lst1 and lst2. Return whichever list has fewer total characters across all its strings. If both lists have the same total character count, return lst1 (the first list). | [
{
"id": "C1",
"description": "Returns list with fewer total characters",
"test_code": "result = solution(['hi', 'admin'], ['hi', 'hi', 'admin', 'project'])\nassert result == ['hi', 'admin'], f\"Expected ['hi', 'admin'], got {result}\""
},
{
"id": "C2",
"description": "Returns first list when... | [
"C1"
] | [
"C2",
"C3"
] |
HumanEval/64 | algorithm | Write a function named `solution` that takes a string and returns the number of vowels in it. Vowels are 'a', 'e', 'i', 'o', 'u'. | Write a function named `solution` that takes a string and returns the number of vowels in it, counting both uppercase and lowercase 'a', 'e', 'i', 'o', 'u'. The letter 'y' also counts as a vowel, but only when it is the last character of the string. | [
{
"id": "C1",
"description": "Basic vowel count works",
"test_code": "result = solution('abcde')\nassert result == 2, f\"Expected 2, got {result}\""
},
{
"id": "C2",
"description": "Counts uppercase vowels and trailing Y together",
"test_code": "result = solution('ACEDY')\nassert result ... | [
"C1"
] | [
"C2",
"C3",
"C4"
] |
HumanEval/66 | algorithm | Write a function named `solution` that takes a string and returns the sum of ASCII codes of its characters. | Write a function named `solution` that takes a string and returns the sum of ASCII codes of only the uppercase characters in the string. Lowercase letters and other characters are not included in the sum. | [
{
"id": "C1",
"description": "Basic sum-of-all-characters case works (matches ambiguous prompt literally)",
"test_code": "result = solution('AB')\nassert result == 131, f\"Expected 131, got {result}\""
},
{
"id": "C2",
"description": "Only uppercase letters are counted, lowercase excluded",
... | [
"C1"
] | [
"C2",
"C3"
] |
HumanEval/71 | algorithm | Write a function named `solution` that takes the lengths of three sides and returns the area of the triangle. | Write a function named `solution` that takes the lengths of three sides of a triangle and returns the area rounded to 2 decimal points. Three sides form a valid triangle when the sum of any two sides is greater than the third. If the sides do not form a valid triangle, return -1. | [
{
"id": "C1",
"description": "Basic area calculation works for valid triangle",
"test_code": "result = solution(3, 4, 5)\nassert result == 6.00, f\"Expected 6.00, got {result}\""
},
{
"id": "C2",
"description": "Returns -1 for invalid triangle (fails triangle inequality)",
"test_code": "... | [
"C1"
] | [
"C2",
"C3"
] |
HumanEval/86 | algorithm | Write a function named `solution` that takes a string and returns a version where the characters are arranged in ascending order based on ASCII value. | Write a function named `solution` that takes a string and returns an ordered version of it. Words (separated by single spaces) should each have their characters individually rearranged in ascending ASCII order. The order of the words and the spaces between them should be preserved. | [
{
"id": "C1",
"description": "Basic character ordering within a single word works",
"test_code": "result = solution('cba')\nassert result == 'abc', f\"Expected 'abc', got {result}\""
},
{
"id": "C2",
"description": "Word boundaries are preserved, not sorted across whole string",
"test_co... | [
"C1"
] | [
"C2",
"C3"
] |
HumanEval/90 | algorithm | Write a function named `solution` that returns the 2nd smallest element of the list. | Write a function named `solution` that takes a list of integers and returns the 2nd smallest element of the list. Return None if there is no such element. | [
{
"id": "C1",
"description": "Returns 2nd smallest element",
"test_code": "result = solution([1, 2, 3, 4, 5])\nassert result == 2, f\"Expected 2, got {result}\""
},
{
"id": "C2",
"description": "Can handle unsorted lists",
"test_code": "result = solution([5, 10, 2, 1, 13, 60])\nassert re... | [
"C1"
] | [
"C2",
"C3",
"C4"
] |
HumanEval/95 | algorithm | Write a function named `solution` that returns True if all keys are in lower or upper case. | Write a function named `solution` that takes a dictionary and returns True if all keys are strings in lower case, or all keys are strings in upper case. Return False if the keys are mixed case or if the dictionary is empty. | [
{
"id": "C1",
"description": "Returns True when all keys are lowercase",
"test_code": "result = solution({'a': 1, 'b': 2})\nassert result == True, f\"Expected True, got {result}\""
},
{
"id": "C2",
"description": "Returns True when all keys are uppercase",
"test_code": "result = solution... | [
"C1"
] | [
"C2",
"C3",
"C4"
] |
HumanEval/98 | algorithm | Write a function named `solution` that returns the number of uppercase vowels on even indices. | Write a function named `solution` that takes a string and counts the number of uppercase vowels that have an even-numbered index (0-indexed). If the string is empty, it should return 0 instead of None or raising an error. | [
{
"id": "C1",
"description": "Returns correct count of uppercase vowels on even indices",
"test_code": "result = solution('aEIoU')\nassert result == 2, f\"Expected 2, got {result}\""
},
{
"id": "C2",
"description": "Returns 0 for empty string rather than None or error",
"test_code": "res... | [
"C1"
] | [
"C2"
] |
HumanEval/99 | algorithm | Write a function named `solution` that takes a value (string) representing a number and returns the closest integer to it. | Write a function named `solution` that takes a value (string) representing a number and returns the closest integer to it. If the number is exactly equidistant between two integers, round away from zero (not banker's rounding). For example, 14.5 rounds to 15, and -14.5 rounds to -15. | [
{
"id": "C1",
"description": "Basic rounding works for non-tie cases",
"test_code": "result = solution('15.3')\nassert result == 15, f\"Expected 15, got {result}\""
},
{
"id": "C2",
"description": "Ties round away from zero for positive numbers",
"test_code": "result = solution('14.5')\n... | [
"C1"
] | [
"C2",
"C3"
] |
HumanEval/102 | algorithm | Write a function named `solution` that takes two positive numbers and returns the biggest even number within their range. | Write a function named `solution` that takes two positive numbers x and y, and returns the biggest even number in the inclusive range [x, y]. If no even number exists in that range, return -1. | [
{
"id": "C1",
"description": "Returns biggest even number within range",
"test_code": "result = solution(1, 5)\nassert result == 4, f\"Expected 4, got {result}\""
},
{
"id": "C2",
"description": "Range is inclusive of the endpoints",
"test_code": "result = solution(1, 4)\nassert result =... | [
"C1"
] | [
"C2",
"C3"
] |
HumanEval/104 | algorithm | Write a function named `solution` that takes a list of positive integers and returns only the ones where every digit is odd. | Write a function named `solution` that takes a list of positive integers and returns a sorted list (ascending order) of only the elements where every digit is odd (no even digits present). | [
{
"id": "C1",
"description": "Filters correctly for numbers with all-odd digits (order not checked)",
"test_code": "result = solution([15, 33, 1422, 1])\nassert set(result) == {1, 15, 33}, f\"Expected elements {{1, 15, 33}}, got {result}\""
},
{
"id": "C2",
"description": "Output is sorted i... | [
"C1"
] | [
"C2",
"C3"
] |
HumanEval/108 | algorithm | Write a function named `solution` that takes an array of integers and returns the count of elements whose digit sum is greater than 0. | Write a function named `solution` that takes an array of integers and returns the count of elements whose digit sum is greater than 0. For negative numbers, treat the first digit as negative when summing (e.g., -123 has signed digits -1, 2, 3, summing to 4). | [
{
"id": "C1",
"description": "Basic digit sum count works for positive numbers",
"test_code": "result = solution([1, 11, -1, -11, 4])\nassert result == 3, f\"Expected 3, got {result}\""
},
{
"id": "C2",
"description": "Negative single-digit numbers are treated as negative, not counted",
... | [
"C1"
] | [
"C2",
"C3"
] |
HumanEval/120 | algorithm | Write a function named `solution` that takes an array of integers and a positive integer k, and returns a sorted list of the k largest numbers in the array. | Write a function named `solution` that takes an array of integers and a positive integer k, and returns a sorted list (ascending order) containing the k largest numbers in the array. | [
{
"id": "C1",
"description": "Basic k largest numbers works",
"test_code": "result = solution([-3, -4, 5], 3)\nassert result == [-4, -3, 5], f\"Expected [-4, -3, 5], got {result}\""
},
{
"id": "C2",
"description": "Output is sorted ascending, not descending",
"test_code": "result = solut... | [
"C1"
] | [
"C2",
"C3"
] |
HumanEval/126 | algorithm | Write a function named `solution` that takes a list of numbers and returns True if sorted in ascending order. Assume no negative numbers, and only integers. | Write a function named `solution` that takes a list of numbers and returns True if sorted in ascending order. If any number appears more than twice in the list, return False regardless of sort order. An empty list is considered sorted and returns True. Assume no negative numbers, and only integers. | [
{
"id": "C1",
"description": "Works on basic ascending case",
"test_code": "result = solution([1, 2, 3, 4])\nassert result == True, f\"Expected True, got {result}\""
},
{
"id": "C2",
"description": "Allows one duplicate per number, still sorted",
"test_code": "result = solution([1, 2, 2,... | [
"C1"
] | [
"C2",
"C3",
"C4"
] |
HumanEval/91 | algorithm | Write a function named `solution` that takes a string of sentences and counts how many sentences start with 'I'. Sentences are delimited by periods, question marks, or exclamation marks. | Write a function named `solution` that takes a string of sentences and counts how many sentences start with the standalone word 'I' (not words merely beginning with 'I' like 'Is' or 'It'). Sentences are delimited by periods, question marks, or exclamation marks. | [
{
"id": "C1",
"description": "Basic case works for sentence starting with 'I'",
"test_code": "result = solution('The sky is blue. The sun is shining. I love this weather')\nassert result == 1, f\"Expected 1, got {result}\""
},
{
"id": "C2",
"description": "Words merely starting with 'I' (lik... | [
"C1"
] | [
"C2",
"C3"
] |
HumanEval/131 | algorithm | Write a function named `solution` that takes a positive integer n and returns the product of the odd digits. | Write a function named `solution` that takes a positive integer n and returns the product of the odd digits. Return 0 if all digits are even. | [
{
"id": "C1",
"description": "Basic case of product of odd digits works.",
"test_code": "result = solution(15)\nassert result == 5, f\"Expected 5, got {result}\""
},
{
"id": "C2",
"description": "Handles all even case properly.",
"test_code": "result = solution(22)\nassert result == 0, f... | [
"C1"
] | [
"C2"
] |
HumanEval/135 | algorithm | Write a function named `solution` that returns the largest index of an element which is not greater than or equal to the element immediately preceding it. The given array will not contain duplicate values. | Write a function named `solution` that returns the largest index of an element which is not greater than or equal to the element immediately preceding it. If no such element exists, return -1. The given array will not contain duplicate values. | [
{
"id": "C1",
"description": "Basic case of largest index violating non-decreasing order works",
"test_code": "result = solution([5, 4, 6, 7, 8])\nassert result == 1, f\"Expected 1, got {result}\""
},
{
"id": "C2",
"description": "Handles non-existing case, returns -1",
"test_code": "res... | [
"C1"
] | [
"C2"
] |
HumanEval/136 | algorithm | Write a function named `solution` that takes a list of integers and returns a tuple (a, b), where a is the largest negative integer and b is the smallest positive integer in the list. | Write a function named `solution` that takes a list of integers and returns a tuple (a, b), where a is the largest negative integer and b is the smallest positive integer in the list. Zero counts as neither positive nor negative. If no negative integers exist, a is None. If no positive integers exist, b is None. | [
{
"id": "C1",
"description": "Basic case works when both negative and positive exist",
"test_code": "result = solution([1, 3, 2, 4, 5, 6, -2])\nassert tuple(result) == (-2, 1), f\"Expected (-2, 1), got {result}\""
},
{
"id": "C2",
"description": "Zero is not counted as positive or negative",... | [
"C1"
] | [
"C2",
"C3"
] |
HumanEval/140 | algorithm | Write a function named `solution` that takes a string and replaces spaces with underscores. If there are multiple consecutive spaces, replace them with a dash instead. | Write a function named `solution` that takes a string and replaces single spaces with underscores. If there are more than 2 consecutive spaces (3 or more), replace the entire run of spaces with a single dash instead of an underscore per space. | [
{
"id": "C1",
"description": "Single space becomes underscore",
"test_code": "result = solution('Example 1')\nassert result == 'Example_1', f\"Expected 'Example_1', got {result}\""
},
{
"id": "C2",
"description": "Exactly 2 consecutive spaces become 2 underscores, not a dash (threshold is 3+... | [
"C1"
] | [
"C2",
"C3"
] |
HumanEval/149 | algorithm | Write a function named `solution` that takes a list of strings, removes strings with odd length, and returns the result sorted by length in ascending order. | Write a function named `solution` that takes a list of strings, removes strings with odd length (keeping only even-length strings), and returns the result sorted by length in ascending order. If two strings have the same length, sort them alphabetically. | [
{
"id": "C1",
"description": "Basic filtering and sorting by length works",
"test_code": "result = solution(['aa', 'a', 'aaa'])\nassert result == ['aa'], f\"Expected ['aa'], got {result}\""
},
{
"id": "C2",
"description": "Ties in length are sorted alphabetically",
"test_code": "result =... | [
"C1"
] | [
"C2",
"C3"
] |
HumanEval/151 | algorithm | Write a function named `solution` that takes a list of numbers and returns the sum of squares of numbers in the list that are odd. | Write a function named `solution` that takes a list of numbers and returns the sum of squares of numbers in the list that are odd. Ignore numbers that are negative or not whole integers (e.g., floats with decimal parts). Return 0 for an empty list. | [
{
"id": "C1",
"description": "Basic case works",
"test_code": "result = solution([1, 2, 3])\nassert result == 10, f\"Expected 10, got {result}\""
},
{
"id": "C2",
"description": "Ignores negative numbers and non-integer (decimal) values",
"test_code": "result = solution([1, 3, -5, 0.5, 2... | [
"C1"
] | [
"C2",
"C3"
] |
HumanEval/158 | algorithm | Write a function named `solution` that takes a list of strings and returns the word with the maximum number of unique characters. | Write a function named `solution` that takes a list of strings and returns the word with the maximum number of unique characters. If multiple words share the same maximum count of unique characters, return the one that comes first in lexicographical order. | [
{
"id": "C1",
"description": "Uses unique character count, not total string length",
"test_code": "result = solution(['aabb', 'abcd'])\nassert result == 'abcd', f\"Expected 'abcd' (4 unique chars vs 2), got {result}\""
},
{
"id": "C2",
"description": "Ties in unique character count resolve l... | [
"C1"
] | [
"C2"
] |
HumanEval/163 | algorithm | Write a function named `solution` that takes two positive integers a and b, and returns the even digits between a and b. | Write a function named `solution` that takes two positive integers a and b, and returns the even single digits (0-9) between a and b, in ascending order, inclusive of endpoints. Works regardless of whether a or b is larger. | [
{
"id": "C1",
"description": "Basic case works",
"test_code": "result = solution(2, 8)\nassert result == [2, 4, 6, 8], f\"Expected [2, 4, 6, 8], got {result}\""
},
{
"id": "C2",
"description": "Result is capped at single digits (0-9), even if b is larger",
"test_code": "result = solution... | [
"C1"
] | [
"C2",
"C3"
] |
HumanEval/88 | algorithm | Write a function named `solution` that takes an array of non-negative integers and returns a sorted copy of the array, without modifying the original. | Write a function named `solution` that takes an array of non-negative integers and returns a sorted copy. Sort in ascending order if the sum of the first and last elements is odd, or descending order if that sum is even. Do not mutate the input array. | [
{
"id": "C1",
"description": "Basic sorting works when sum is odd (ascending)",
"test_code": "result = solution([2, 4, 3, 0, 1, 5])\nassert result == [0, 1, 2, 3, 4, 5], f\"Expected [0, 1, 2, 3, 4, 5], got {result}\""
},
{
"id": "C2",
"description": "Sorts descending when sum of first and la... | [
"C1"
] | [
"C2",
"C3"
] |
HumanEval/93 | algorithm | Write a function named `solution` that takes a message and swaps the case of all letters. | Write a function named `solution` that takes a message, swaps the case of all letters, and then replaces all vowels (a, e, i, o, u, both cases) with the letter that appears 2 places ahead of it in the alphabet. Case swapping happens first, then the vowel shift is applied to the result. | [
{
"id": "C1",
"description": "Basic case swap works (vowel-free input, isolates case-swap only)",
"test_code": "result = solution('Xyz')\nassert result == 'xYZ', f\"Expected 'xYZ', got {result}\""
},
{
"id": "C2",
"description": "Vowels are shifted 2 places ahead after case swap",
"test_... | [
"C1"
] | [
"C2",
"C3"
] |
HumanEval/101 | algorithm | Write a function named `solution` that takes a string of words separated by commas and returns a list of the words. | Write a function named `solution` that takes a string of words separated by commas, spaces, or both, and returns a list of the words with no empty strings in the result, even if there are consecutive delimiters. | [
{
"id": "C1",
"description": "Basic comma-separated case works",
"test_code": "result = solution('One, two, three')\nassert result == ['One', 'two', 'three'], f\"Expected ['One', 'two', 'three'], got {result}\""
},
{
"id": "C2",
"description": "Handles space-only separated words too",
"t... | [
"C1"
] | [
"C2",
"C3"
] |
HumanEval/105 | algorithm | Write a function named `solution` that takes an array of integers, sorts the values, reverses the order, and returns a list where each value is replaced by its corresponding number name (One, Two, Three, ... Nine). | Write a function named `solution` that takes an array of integers, keeps only values between 1 and 9 inclusive, sorts them, reverses the order, and returns a list where each remaining value is replaced by its corresponding number name (One through Nine). Values outside 1-9 are silently ignored rather than causing an er... | [
{
"id": "C1",
"description": "Basic sort, reverse, and name conversion works",
"test_code": "result = solution([2, 1, 1, 4, 5, 8, 2, 3])\nassert result == ['Eight', 'Five', 'Four', 'Three', 'Two', 'Two', 'One', 'One'], f\"Expected the reversed named list, got {result}\""
},
{
"id": "C2",
"de... | [
"C1"
] | [
"C2",
"C3"
] |
HumanEval/111 | algorithm | Write a function named `solution` that takes a space-separated string of lowercase letters and returns a dictionary of the letter with the most repetitions and its count. | Write a function named `solution` that takes a space-separated string of lowercase letters and returns a dictionary mapping each letter to its count, but only including letters that have the maximum occurrence count. If multiple letters are tied for the maximum, include all of them. Return an empty dictionary for an em... | [
{
"id": "C1",
"description": "Basic case with a single most-frequent letter works",
"test_code": "result = solution('b b b b a')\nassert result == {'b': 4}, f\"Expected {{'b': 4}}, got {result}\""
},
{
"id": "C2",
"description": "Returns all letters tied for the maximum count, not just one",... | [
"C1"
] | [
"C2",
"C3"
] |
HumanEval/112 | algorithm | Write a function named `solution` that takes two strings s and c, removes from s any character that appears in c, and checks if the resulting string is a palindrome. | Write a function named `solution` that takes two strings s and c, removes from s any character that appears in c, and returns a tuple (result_string, is_palindrome) where is_palindrome is True if the resulting string reads the same forwards and backwards. | [
{
"id": "C1",
"description": "Basic filtering and palindrome check works",
"test_code": "result = solution('abcde', 'ae')\nassert tuple(result) == ('bcd', False), f\"Expected ('bcd', False), got {result}\""
},
{
"id": "C2",
"description": "Returns a tuple with result string as first element ... | [
"C1"
] | [
"C2",
"C3"
] |
HumanEval/145 | algorithm | Write a function named `solution` that takes a list of integers and sorts them in ascending order according to the sum of their digits. | Write a function named `solution` that takes a list of integers and sorts them in ascending order by the sum of their digits. For negative numbers, treat the first digit as negative when summing (e.g., -11 has digit sum -1-1=-2). If multiple items have the same digit sum, preserve their original relative order (stable ... | [
{
"id": "C1",
"description": "Basic digit-sum sorting works for positive numbers, no ties",
"test_code": "result = solution([100, 25, 3])\nassert result == [100, 3, 25], f\"Expected [100, 3, 25], got {result}\""
},
{
"id": "C2",
"description": "Negative numbers treat first digit as negative ... | [
"C1"
] | [
"C2",
"C3"
] |
HumanEval/161 | algorithm | Write a function named `solution` that takes a string and swaps the case of each letter, leaving non-letter characters unchanged. | Write a function named `solution` that takes a string and swaps the case of each letter (lower to upper, upper to lower), leaving non-letter characters unchanged. If the string contains no letters at all, return the string reversed instead. | [
{
"id": "C1",
"description": "Basic case swap works, non-letters unchanged",
"test_code": "result = solution('#a@C')\nassert result == '#A@c', f\"Expected '#A@c', got {result}\""
},
{
"id": "C2",
"description": "String with no letters is reversed instead of returned as-is",
"test_code": ... | [
"C1"
] | [
"C2"
] |
IntentSpec Benchmark — Data Supplement
This archive contains the benchmark data used to compute Intent Violation Rate (IVR) in the paper: 49 tasks, each derived from a HumanEval problem and extended with an ambiguous/gold prompt pair and a decomposed set of executable constraints.
Files
spec_pairs.jsonl
The benchmark itself — one JSON object per line, one line per task. This is
the file consumed directly by the evaluation pipeline (run_experiment1.py,
validate_benchmark.py in the software supplement).
Fields:
| Field | Type | Description |
|---|---|---|
task_id |
string | HumanEval task identifier, e.g. "HumanEval/26". Matches the task_id in canonicals.jsonl. |
spec_type |
string | Category of the task. Currently always "algorithm". |
ambiguous_prompt |
string | The under-specified prompt a developer might plausibly write — states only some of the task's real constraints. |
gold_prompt |
string | The fully clarified version of the prompt, stating every constraint explicitly. |
constraints |
list of objects | All atomic, executable constraints implied by the gold prompt (see below). |
stated_test_ids |
list of strings | IDs (from constraints) that are mentioned, even implicitly, in ambiguous_prompt. |
hidden_test_ids |
list of strings | IDs (from constraints) that appear only in gold_prompt, not in ambiguous_prompt. A solution that passes all stated_test_ids but fails one or more hidden_test_ids counts as an intent violation — this is what IVR measures. |
Each entry in constraints is an object:
| Field | Type | Description |
|---|---|---|
id |
string | Local constraint identifier (e.g. "C1"), referenced by stated_test_ids/hidden_test_ids. |
description |
string | Human-readable statement of the constraint. |
test_code |
string | Executable Python snippet that calls solution(...) and asserts the constraint holds. Run by concatenating a candidate solution with this snippet and executing it; a zero exit code means the constraint passed. |
Example (abbreviated):
{
"task_id": "HumanEval/26",
"spec_type": "algorithm",
"ambiguous_prompt": "Write a function named `solution` that takes a list of integers and removes any elements that appear more than once.",
"gold_prompt": "Write a function named `solution` that takes a list of integers, removes all elements that occur more than once, preserves the original order of remaining elements, and returns a new list without mutating the input.",
"constraints": [
{"id": "C1", "description": "Elements appearing more than once are removed", "test_code": "result = solution([1, 2, 3, 2, 4])\nassert 2 not in result"},
{"id": "C2", "description": "Original order of remaining elements is preserved", "test_code": "..."},
{"id": "C3", "description": "Input list is not mutated", "test_code": "..."},
{"id": "C4", "description": "Empty list returns empty list", "test_code": "..."}
],
"stated_test_ids": ["C1"],
"hidden_test_ids": ["C2", "C3", "C4"]
}
canonicals.jsonl
The original HumanEval reference (gold) solutions that spec_pairs.jsonl
was built from. Used for benchmark validation — confirming that a correct,
known-good solution passes every constraint (stated and hidden) for its
task, i.e. that IVR == 0 for canonical solutions.
Fields:
| Field | Type | Description |
|---|---|---|
task_id |
string | HumanEval task identifier, matches spec_pairs.jsonl. |
entry_point |
string | Name of the function under test in the original HumanEval problem. |
prompt |
string | Original HumanEval function signature + docstring. |
canonical_solution |
string | Original HumanEval reference implementation body. |
full_source |
string | prompt + canonical_solution concatenated into a runnable module. |
Provenance and licensing
Both files are derived from HumanEval
(https://github.com/openai/human-eval), released by OpenAI under the
MIT License. canonicals.jsonl reproduces HumanEval's original prompts
and reference solutions verbatim (field-renamed for our pipeline).
spec_pairs.jsonl is new work built on top of HumanEval: for each of the 49
selected HumanEval tasks, we authored an ambiguous/gold prompt pair and a
decomposed set of constraint tests by hand, using the HumanEval problem
statement and reference solution as the source of ground truth. task_id
values (e.g. "HumanEval/26") directly reference the corresponding upstream
HumanEval problem.
This derived data is released under the same MIT License as HumanEval, in accordance with its terms.
- Downloads last month
- 43