{"id": "8f5dff3040767b3d0e3be1c154c6ee82", "language": "python", "function_name": "find_max", "function_code": "def find_max(nums: list[int]) -> int:\n if not nums:\n raise ValueError(\"List must not be empty\")\n return max(nums)", "edge_case_type": "single_element", "edge_case_description": "single-element list returns that element", "test_framework": "pytest", "unit_test": "def test_find_max_single():\n assert find_max([42]) == 42", "difficulty": "easy"} {"id": "1788eb26f588d778d8e55afa9ee47216", "language": "java", "function_name": "clamp", "function_code": "public static double clamp(double value, double lo, double hi) {\n return Math.max(lo, Math.min(hi, value));\n}", "edge_case_type": "within", "edge_case_description": "value within range returned unchanged", "test_framework": "junit4", "unit_test": "@Test\npublic void testClampWithin() {\n assertEquals(5.0, clamp(5, 0, 10), 1e-9);\n}", "difficulty": "medium"} {"id": "addf121b5d1613a2d31fe7307621156f", "language": "go", "function_name": "FindMax", "function_code": "func FindMax(nums []int) (int, error) {\n\tif len(nums) == 0 {\n\t\treturn 0, errors.New(\"empty slice\")\n\t}\n\tmax := nums[0]\n\tfor _, v := range nums[1:] {\n\t\tif v > max {\n\t\t\tmax = v\n\t\t}\n\t}\n\treturn max, nil\n}", "edge_case_type": "duplicates", "edge_case_description": "duplicate max values return that max", "test_framework": "testing", "unit_test": "func TestFindMaxDuplicates(t *testing.T) {\n\tv, _ := FindMax([]int{5, 5, 3})\n\tif v != 5 {\n\t\tt.Errorf(\"expected 5, got %v\", v)\n\t}\n}", "difficulty": "medium"} {"id": "3c212b51bd9ea9c67889bdd414e6fe68", "language": "javascript", "function_name": "uniqueBy", "function_code": "function uniqueBy(arr, key) {\n const seen = new Set();\n return arr.filter(item => {\n const k = item[key];\n if (seen.has(k)) return false;\n seen.add(k);\n return true;\n });\n}", "edge_case_type": "no_duplicates", "edge_case_description": "no duplicate keys passes all through", "test_framework": "jest", "unit_test": "test(\"uniqueBy no dups\", () => {\n const items = [{id:1},{id:2}];\n expect(uniqueBy(items,\"id\").length).toBe(2);\n});", "difficulty": "easy"} {"id": "7c231578d42808899d8933a0ffe97e27", "language": "rust", "function_name": "reverse_string", "function_code": "pub fn reverse_string(s: &str) -> String {\n s.chars().rev().collect()\n}", "edge_case_type": "unicode", "edge_case_description": "unicode chars reversed by char boundary", "test_framework": "rust-test", "unit_test": "#[test]\nfn test_reverse_unicode() {\n assert_eq!(reverse_string(\"h\u00e9llo\"), \"oll\u00e9h\");\n}", "difficulty": "medium"} {"id": "6a2de3841755f519993049225dd35276", "language": "javascript", "function_name": "memoize", "function_code": "function memoize(fn) {\n const cache = new Map();\n return (...args) => {\n const key = JSON.stringify(args);\n if (cache.has(key)) return cache.get(key);\n const result = fn(...args);\n cache.set(key, result);\n return result;\n };\n}", "edge_case_type": "zero_arg", "edge_case_description": "zero-argument function is cached after first call", "test_framework": "jest", "unit_test": "test(\"memoize no args\", () => {\n let calls = 0;\n const fn = memoize(() => { calls++; return 42; });\n expect(fn()).toBe(42);\n expect(fn()).toBe(42);\n expect(calls).toBe(1);\n});", "difficulty": "medium"} {"id": "4cbcb7a2bea1832d809934ef03a6ca55", "language": "typescript", "function_name": "parseJSON", "function_code": "export function parseJSON(s: string): T | null {\n try {\n return JSON.parse(s) as T;\n } catch {\n return null;\n }\n}", "edge_case_type": "null_literal", "edge_case_description": "'null' string parses to null value", "test_framework": "jest", "unit_test": "test('parseJSON null literal', () => {\n expect(parseJSON('null')).toBeNull();\n});", "difficulty": "medium"} {"id": "8612040f0ee4f49f60b57ed3b7f48922", "language": "typescript", "function_name": "chunk", "function_code": "export function chunk(arr: T[], size: number): T[][] {\n if (size <= 0) throw new Error('size must be positive');\n const result: T[][] = [];\n for (let i = 0; i < arr.length; i += size) result.push(arr.slice(i, i + size));\n return result;\n}", "edge_case_type": "size_zero", "edge_case_description": "size 0 throws", "test_framework": "jest", "unit_test": "test('chunk zero size', () => {\n expect(() => chunk([1,2,3], 0)).toThrow();\n});", "difficulty": "medium"} {"id": "0fb557da8453317d8d032f507c7e1c2a", "language": "typescript", "function_name": "chunk", "function_code": "export function chunk(arr: T[], size: number): T[][] {\n if (size <= 0) throw new Error('size must be positive');\n const result: T[][] = [];\n for (let i = 0; i < arr.length; i += size) result.push(arr.slice(i, i + size));\n return result;\n}", "edge_case_type": "remainder", "edge_case_description": "uneven length last chunk is smaller", "test_framework": "jest", "unit_test": "test('chunk remainder', () => {\n expect(chunk([1,2,3,4,5],2)).toEqual([[1,2],[3,4],[5]]);\n});", "difficulty": "medium"} {"id": "180ccdd8db9c2ebe7bf7889adc9c3257", "language": "python", "function_name": "gcd", "function_code": "def gcd(a: int, b: int) -> int:\n while b:\n a, b = b, a % b\n return a", "edge_case_type": "coprime", "edge_case_description": "gcd of coprime numbers is 1", "test_framework": "pytest", "unit_test": "def test_gcd_coprime():\n assert gcd(13, 7) == 1", "difficulty": "medium"} {"id": "85c8bda3653f84986142ed4b13db50e4", "language": "python", "function_name": "celsius_to_fahrenheit", "function_code": "def celsius_to_fahrenheit(c: float) -> float:\n return c * 9 / 5 + 32", "edge_case_type": "negative_celsius", "edge_case_description": "negative Celsius converts to correct Fahrenheit", "test_framework": "pytest", "unit_test": "def test_celsius_negative():\n assert celsius_to_fahrenheit(-40) == -40.0", "difficulty": "medium"} {"id": "aea7c5e5132313af8e26894fea3d1588", "language": "python", "function_name": "chunk_list", "function_code": "def chunk_list(lst: list, size: int) -> list[list]:\n if size <= 0:\n raise ValueError(\"size must be positive\")\n return [lst[i:i + size] for i in range(0, len(lst), size)]", "edge_case_type": "exact_multiple", "edge_case_description": "list length is exact multiple of chunk size", "test_framework": "pytest", "unit_test": "def test_chunk_exact():\n assert chunk_list([1, 2, 3, 4], 2) == [[1, 2], [3, 4]]", "difficulty": "easy"} {"id": "3d71fbca6d366aa728075274984f1ce4", "language": "python", "function_name": "fizzbuzz", "function_code": "def fizzbuzz(n: int) -> str:\n if n % 15 == 0:\n return \"FizzBuzz\"\n if n % 3 == 0:\n return \"Fizz\"\n if n % 5 == 0:\n return \"Buzz\"\n return str(n)", "edge_case_type": "not_divisible", "edge_case_description": "number not divisible by 3 or 5 returns string of n", "test_framework": "pytest", "unit_test": "def test_fizzbuzz_plain():\n assert fizzbuzz(7) == \"7\"", "difficulty": "medium"} {"id": "a32ed98cf96d9012c648921a362084d9", "language": "python", "function_name": "factorial", "function_code": "def factorial(n: int) -> int:\n if n < 0:\n raise ValueError(\"n must be non-negative\")\n if n == 0:\n return 1\n return n * factorial(n - 1)", "edge_case_type": "one_input", "edge_case_description": "factorial of 1 is 1", "test_framework": "pytest", "unit_test": "def test_factorial_one():\n assert factorial(1) == 1", "difficulty": "easy"} {"id": "ffb235335b0ef809c4cec992ef39596d", "language": "java", "function_name": "factorial", "function_code": "public static long factorial(int n) {\n if (n < 0) throw new IllegalArgumentException(\"n must be non-negative\");\n long result = 1;\n for (int i = 2; i <= n; i++) result *= i;\n return result;\n}", "edge_case_type": "zero", "edge_case_description": "factorial(0) is 1", "test_framework": "junit4", "unit_test": "@Test\npublic void testFactorialZero() {\n assertEquals(1L, factorial(0));\n}", "difficulty": "easy"} {"id": "457bd0bd1bb017bb43babf394df00a5c", "language": "python", "function_name": "cumulative_sum", "function_code": "def cumulative_sum(nums: list[int]) -> list[int]:\n \"\"\"Return running cumulative sum of nums.\"\"\"\n result, total = [], 0\n for n in nums:\n total += n\n result.append(total)\n return result", "edge_case_type": "empty_list", "edge_case_description": "empty list returns empty list", "test_framework": "pytest", "unit_test": "def test_cumsum_empty():\n assert cumulative_sum([]) == []", "difficulty": "easy"} {"id": "aabab1f1c05a1017d430f38f2f5f78e3", "language": "java", "function_name": "wordCount", "function_code": "public static Map wordCount(String text) {\n Map counts = new HashMap<>();\n if (text == null || text.isBlank()) return counts;\n for (String word : text.toLowerCase().split(\"\\\\s+\")) {\n counts.merge(word, 1, Integer::sum);\n }\n return counts;\n}", "edge_case_type": "null_input", "edge_case_description": "null input returns empty map", "test_framework": "junit4", "unit_test": "@Test\npublic void testWordCountNull() {\n assertTrue(wordCount(null).isEmpty());\n}", "difficulty": "medium"} {"id": "c7470fa12d5ba01e87a7f9c8c40bd95c", "language": "java", "function_name": "findMax", "function_code": "public static int findMax(int[] arr) {\n if (arr.length == 0) throw new IllegalArgumentException(\"Array is empty\");\n int max = arr[0];\n for (int v : arr) if (v > max) max = v;\n return max;\n}", "edge_case_type": "duplicates", "edge_case_description": "max value appears multiple times", "test_framework": "junit4", "unit_test": "@Test\npublic void testFindMaxDuplicates() {\n assertEquals(5, findMax(new int[]{5, 5, 3}));\n}", "difficulty": "medium"} {"id": "8f08b93f7068fd80a6c96537f9da42aa", "language": "java", "function_name": "reverseString", "function_code": "public static String reverseString(String s) {\n return new StringBuilder(s).reverse().toString();\n}", "edge_case_type": "palindrome", "edge_case_description": "palindrome returns itself", "test_framework": "junit4", "unit_test": "@Test\npublic void testReversePalindrome() {\n assertEquals(\"racecar\", reverseString(\"racecar\"));\n}", "difficulty": "easy"} {"id": "6ed22e9d050c298707a04e77acccf275", "language": "typescript", "function_name": "pick", "function_code": "export function pick(obj: T, keys: K[]): Pick {\n const result = {} as Pick;\n for (const k of keys) {\n if (k in obj) result[k] = obj[k];\n }\n return result;\n}", "edge_case_type": "all_keys", "edge_case_description": "picking all keys returns equivalent object", "test_framework": "jest", "unit_test": "test('pick all keys', () => {\n expect(pick({a:1,b:2}, ['a','b'])).toEqual({a:1,b:2});\n});", "difficulty": "easy"} {"id": "1557f66d45ec09226cc6cc9593be7a2b", "language": "rust", "function_name": "divide", "function_code": "pub fn divide(a: f64, b: f64) -> Result {\n if b == 0.0 {\n return Err(\"Division by zero\".to_string());\n }\n Ok(a / b)\n}", "edge_case_type": "both_negative", "edge_case_description": "both negative yields positive", "test_framework": "rust-test", "unit_test": "#[test]\nfn test_divide_both_neg() {\n assert_eq!(divide(-6.0, -3.0).unwrap(), 2.0);\n}", "difficulty": "medium"} {"id": "c798c3654d6c54b0d71a4cafefe1a856", "language": "typescript", "function_name": "deepEqual", "function_code": "export function deepEqual(a: unknown, b: unknown): boolean {\n return JSON.stringify(a) === JSON.stringify(b);\n}", "edge_case_type": "array_order", "edge_case_description": "array order matters for equality", "test_framework": "jest", "unit_test": "test('deepEqual array order', () => {\n expect(deepEqual([1,2], [2,1])).toBe(false);\n});", "difficulty": "medium"} {"id": "13ba608609022f7d7a6cf3d44b170c28", "language": "rust", "function_name": "clamp", "function_code": "pub fn clamp(value: f64, lo: f64, hi: f64) -> f64 {\n if value < lo { lo } else if value > hi { hi } else { value }\n}", "edge_case_type": "within", "edge_case_description": "value within range unchanged", "test_framework": "rust-test", "unit_test": "#[test]\nfn test_clamp_within() {\n assert_eq!(clamp(5.0, 0.0, 10.0), 5.0);\n}", "difficulty": "medium"} {"id": "cae23a2c6b4b1d23604ef44e5917d13e", "language": "javascript", "function_name": "divide", "function_code": "function divide(a, b) {\n if (b === 0) throw new Error('Division by zero');\n return a / b;\n}", "edge_case_type": "negative_inputs", "edge_case_description": "negative numerator and positive divisor", "test_framework": "jest", "unit_test": "test(\"divide negative numerator\", () => {\n expect(divide(-10, 2)).toBe(-5);\n});", "difficulty": "medium"} {"id": "2e1b377a50fb8f018e87aad02e4883c4", "language": "python", "function_name": "truncate", "function_code": "def truncate(s: str, max_len: int) -> str:\n if len(s) <= max_len:\n return s\n return s[:max_len] + \"...\"", "edge_case_type": "empty_string", "edge_case_description": "empty string is returned unchanged", "test_framework": "pytest", "unit_test": "def test_truncate_empty():\n assert truncate(\"\", 5) == \"\"", "difficulty": "easy"} {"id": "d7fdafdec0c62c7e899b81deeac2db3b", "language": "java", "function_name": "divide", "function_code": "public static double divide(double a, double b) {\n if (b == 0) throw new ArithmeticException(\"Division by zero\");\n return a / b;\n}", "edge_case_type": "both_negative", "edge_case_description": "both negative operands yield positive", "test_framework": "junit4", "unit_test": "@Test\npublic void testDivideBothNegative() {\n assertEquals(2.0, divide(-6, -3), 1e-9);\n}", "difficulty": "medium"} {"id": "45895352d09abbbb9c9cb89a6098023b", "language": "rust", "function_name": "divide", "function_code": "pub fn divide(a: f64, b: f64) -> Result {\n if b == 0.0 {\n return Err(\"Division by zero\".to_string());\n }\n Ok(a / b)\n}", "edge_case_type": "zero_numerator", "edge_case_description": "a=0 returns Ok(0)", "test_framework": "rust-test", "unit_test": "#[test]\nfn test_divide_zero_num() {\n assert_eq!(divide(0.0, 5.0).unwrap(), 0.0);\n}", "difficulty": "medium"} {"id": "ea37442ebc50663de3c50c29671be0cc", "language": "python", "function_name": "is_palindrome", "function_code": "def is_palindrome(s: str) -> bool:\n s = s.lower().replace(\" \", \"\")\n return s == s[::-1]", "edge_case_type": "numeric_palindrome", "edge_case_description": "numeric palindrome string is correctly identified", "test_framework": "pytest", "unit_test": "def test_is_palindrome_numeric():\n assert is_palindrome(\"12321\") is True", "difficulty": "medium"} {"id": "3f854021ffd8b18e508a4c93a8ea014b", "language": "go", "function_name": "FindMax", "function_code": "func FindMax(nums []int) (int, error) {\n\tif len(nums) == 0 {\n\t\treturn 0, errors.New(\"empty slice\")\n\t}\n\tmax := nums[0]\n\tfor _, v := range nums[1:] {\n\t\tif v > max {\n\t\t\tmax = v\n\t\t}\n\t}\n\treturn max, nil\n}", "edge_case_type": "empty_slice", "edge_case_description": "empty slice returns error", "test_framework": "testing", "unit_test": "func TestFindMaxEmpty(t *testing.T) {\n\t_, err := FindMax([]int{})\n\tif err == nil {\n\t\tt.Error(\"expected error for empty slice\")\n\t}\n}", "difficulty": "easy"} {"id": "92065080d78afa9978d9888abe5eaa48", "language": "typescript", "function_name": "groupBy", "function_code": "export function groupBy(arr: T[], key: keyof T): Record {\n return arr.reduce((acc, item) => {\n const k = String(item[key]);\n if (!acc[k]) acc[k] = [];\n acc[k].push(item);\n return acc;\n }, {} as Record);\n}", "edge_case_type": "preserves_order", "edge_case_description": "within each group order is preserved", "test_framework": "jest", "unit_test": "test('groupBy order', () => {\n const items = [{k:'a',i:1},{k:'b',i:2},{k:'a',i:3}];\n expect(groupBy(items,'k').a.map(x=>x.i)).toEqual([1,3]);\n});", "difficulty": "medium"} {"id": "4f3d1c32d94185a8bcc0ccdb521270cb", "language": "python", "function_name": "is_palindrome", "function_code": "def is_palindrome(s: str) -> bool:\n s = s.lower().replace(\" \", \"\")\n return s == s[::-1]", "edge_case_type": "case_insensitive", "edge_case_description": "palindrome check is case-insensitive", "test_framework": "pytest", "unit_test": "def test_is_palindrome_case():\n assert is_palindrome(\"Racecar\") is True", "difficulty": "medium"} {"id": "a5a73e0d676dc91cd23561b3ec5fb7c9", "language": "javascript", "function_name": "memoize", "function_code": "function memoize(fn) {\n const cache = new Map();\n return (...args) => {\n const key = JSON.stringify(args);\n if (cache.has(key)) return cache.get(key);\n const result = fn(...args);\n cache.set(key, result);\n return result;\n };\n}", "edge_case_type": "caches_result", "edge_case_description": "memoized function returns cached result on second call", "test_framework": "jest", "unit_test": "test(\"memoize caches\", () => {\n let calls = 0;\n const fn = memoize((x) => { calls++; return x * 2; });\n fn(5);\n fn(5);\n expect(calls).toBe(1);\n});", "difficulty": "medium"} {"id": "52adbc9993afacd03336a571e102e5a5", "language": "python", "function_name": "Stack", "function_code": "class Stack:\n def __init__(self):\n self._data = []\n\n def push(self, item):\n self._data.append(item)\n\n def pop(self):\n if not self._data:\n raise IndexError(\"pop from empty stack\")\n return self._data.pop()\n\n def peek(self):\n if not self._data:\n raise IndexError(\"peek at empty stack\")\n return self._data[-1]\n\n def is_empty(self):\n return len(self._data) == 0\n\n def size(self):\n return len(self._data)", "edge_case_type": "push_duplicate_values", "edge_case_description": "duplicate values are stored and returned in order", "test_framework": "pytest", "unit_test": "def test_stack_duplicates():\n s = Stack()\n s.push(7)\n s.push(7)\n assert s.pop() == 7\n assert s.pop() == 7\n assert s.is_empty()", "difficulty": "medium"} {"id": "8933f14b14463cd2a7fb394f56f7af71", "language": "python", "function_name": "find_max", "function_code": "def find_max(nums: list[int]) -> int:\n if not nums:\n raise ValueError(\"List must not be empty\")\n return max(nums)", "edge_case_type": "already_sorted", "edge_case_description": "sorted list returns last element", "test_framework": "pytest", "unit_test": "def test_find_max_sorted():\n assert find_max([1, 2, 3, 4, 5]) == 5", "difficulty": "medium"} {"id": "8bd86f08f9fa5114c31cf1eef8bc27ae", "language": "python", "function_name": "Stack", "function_code": "class Stack:\n def __init__(self):\n self._data = []\n\n def push(self, item):\n self._data.append(item)\n\n def pop(self):\n if not self._data:\n raise IndexError(\"pop from empty stack\")\n return self._data.pop()\n\n def peek(self):\n if not self._data:\n raise IndexError(\"peek at empty stack\")\n return self._data[-1]\n\n def is_empty(self):\n return len(self._data) == 0\n\n def size(self):\n return len(self._data)", "edge_case_type": "peek_empty", "edge_case_description": "peeking empty stack raises IndexError", "test_framework": "pytest", "unit_test": "import pytest\n\ndef test_stack_peek_empty():\n s = Stack()\n with pytest.raises(IndexError):\n s.peek()", "difficulty": "medium"} {"id": "7fdb430746cc2e3f688f219fd87e71db", "language": "javascript", "function_name": "clamp", "function_code": "function clamp(value, lo, hi) {\n return Math.max(lo, Math.min(hi, value));\n}", "edge_case_type": "above_hi", "edge_case_description": "value above hi returns hi", "test_framework": "jest", "unit_test": "test(\"clamp above hi\", () => {\n expect(clamp(15, 0, 10)).toBe(10);\n});", "difficulty": "easy"} {"id": "bcaed74b65864ccdae525bda7e7aacb2", "language": "python", "function_name": "levenshtein", "function_code": "def levenshtein(s: str, t: str) -> int:\n \"\"\"Compute Levenshtein (edit) distance between s and t.\"\"\"\n m, n = len(s), len(t)\n dp = list(range(n + 1))\n for i in range(1, m + 1):\n prev = dp[0]\n dp[0] = i\n for j in range(1, n + 1):\n tmp = dp[j]\n if s[i-1] == t[j-1]:\n dp[j] = prev\n else:\n dp[j] = 1 + min(prev, dp[j], dp[j-1])\n prev = tmp\n return dp[n]", "edge_case_type": "completely_different", "edge_case_description": "entirely different strings of equal length", "test_framework": "pytest", "unit_test": "def test_lev_different():\n assert levenshtein(\"abc\", \"xyz\") == 3", "difficulty": "medium"} {"id": "472da75d55caa8c6c550bdb47556a461", "language": "python", "function_name": "truncate", "function_code": "def truncate(s: str, max_len: int) -> str:\n if len(s) <= max_len:\n return s\n return s[:max_len] + \"...\"", "edge_case_type": "max_len_zero", "edge_case_description": "max_len of 0 returns only ellipsis", "test_framework": "pytest", "unit_test": "def test_truncate_zero_max():\n assert truncate(\"hello\", 0) == \"...\"", "difficulty": "medium"} {"id": "116028ac4edfc0529916ac5fe8f57876", "language": "javascript", "function_name": "countOccurrences", "function_code": "function countOccurrences(arr, val) {\n return arr.filter(x => x === val).length;\n}", "edge_case_type": "empty_array", "edge_case_description": "empty array returns 0", "test_framework": "jest", "unit_test": "test(\"countOccurrences empty\", () => {\n expect(countOccurrences([], 5)).toBe(0);\n});", "difficulty": "easy"} {"id": "58685c535f2198b6b0339ba74e8fdcfb", "language": "javascript", "function_name": "debounce", "function_code": "function debounce(fn, delay) {\n let timer;\n return (...args) => {\n clearTimeout(timer);\n timer = setTimeout(() => fn(...args), delay);\n };\n}", "edge_case_type": "fires_after_delay", "edge_case_description": "debounced function fires once after delay", "test_framework": "jest", "unit_test": "test(\"debounce fires after delay\", async () => {\n jest.useFakeTimers();\n const fn = jest.fn();\n const debounced = debounce(fn, 100);\n debounced();\n debounced();\n jest.runAllTimers();\n expect(fn).toHaveBeenCalledTimes(1);\n jest.useRealTimers();\n});", "difficulty": "hard"} {"id": "04ca7dcaa2d4532e1369973f9a222455", "language": "typescript", "function_name": "flattenDeep", "function_code": "export function flattenDeep(arr: unknown[]): unknown[] {\n const result: unknown[] = [];\n const stack = [...arr];\n while (stack.length) {\n const item = stack.pop();\n if (Array.isArray(item)) {\n stack.push(...item);\n } else {\n result.unshift(item);\n }\n }\n return result;\n}", "edge_case_type": "already_flat", "edge_case_description": "already flat array returned unchanged", "test_framework": "jest", "unit_test": "test('flattenDeep flat', () => {\n expect(flattenDeep([1,2,3])).toEqual([1,2,3]);\n});", "difficulty": "easy"} {"id": "064cc6e5a5371de7ec1417a2dd8f83be", "language": "python", "function_name": "merge_sorted", "function_code": "def merge_sorted(a: list[int], b: list[int]) -> list[int]:\n \"\"\"Merge two sorted lists into one sorted list.\"\"\"\n result, i, j = [], 0, 0\n while i < len(a) and j < len(b):\n if a[i] <= b[j]:\n result.append(a[i]); i += 1\n else:\n result.append(b[j]); j += 1\n result.extend(a[i:])\n result.extend(b[j:])\n return result", "edge_case_type": "unequal_lengths", "edge_case_description": "one list much longer than the other", "test_framework": "pytest", "unit_test": "def test_merge_unequal():\n assert merge_sorted([1, 2, 3, 4, 5], [3]) == [1, 2, 3, 3, 4, 5]", "difficulty": "medium"} {"id": "82aff88f7640f56a1e2e29f9101eb653", "language": "java", "function_name": "divide", "function_code": "public static double divide(double a, double b) {\n if (b == 0) throw new ArithmeticException(\"Division by zero\");\n return a / b;\n}", "edge_case_type": "negative_numerator", "edge_case_description": "negative numerator returns correct result", "test_framework": "junit4", "unit_test": "@Test\npublic void testDivideNegative() {\n assertEquals(-5.0, divide(-10, 2), 1e-9);\n}", "difficulty": "medium"} {"id": "4f452843be4f55e4e90a472eb4559f81", "language": "python", "function_name": "Stack", "function_code": "class Stack:\n def __init__(self):\n self._data = []\n\n def push(self, item):\n self._data.append(item)\n\n def pop(self):\n if not self._data:\n raise IndexError(\"pop from empty stack\")\n return self._data.pop()\n\n def peek(self):\n if not self._data:\n raise IndexError(\"peek at empty stack\")\n return self._data[-1]\n\n def is_empty(self):\n return len(self._data) == 0\n\n def size(self):\n return len(self._data)", "edge_case_type": "lifo_order", "edge_case_description": "stack returns items in LIFO order", "test_framework": "pytest", "unit_test": "def test_stack_lifo():\n s = Stack()\n for v in [1, 2, 3]:\n s.push(v)\n assert s.pop() == 3\n assert s.pop() == 2\n assert s.pop() == 1", "difficulty": "easy"} {"id": "7e27c43a012f026455db47b06855482b", "language": "javascript", "function_name": "debounce", "function_code": "function debounce(fn, delay) {\n let timer;\n return (...args) => {\n clearTimeout(timer);\n timer = setTimeout(() => fn(...args), delay);\n };\n}", "edge_case_type": "resets_timer", "edge_case_description": "rapid calls reset the timer and fire only once", "test_framework": "jest", "unit_test": "test(\"debounce resets timer\", async () => {\n jest.useFakeTimers();\n const fn = jest.fn();\n const debounced = debounce(fn, 200);\n debounced();\n jest.advanceTimersByTime(100);\n debounced();\n jest.advanceTimersByTime(200);\n expect(fn).toHaveBeenCalledTimes(1);\n jest.useRealTimers();\n});", "difficulty": "hard"} {"id": "f9ad51afefc4c39ca724895c0edfaf9b", "language": "go", "function_name": "Fibonacci", "function_code": "func Fibonacci(n int) (int, error) {\n\tif n < 0 {\n\t\treturn 0, errors.New(\"n must be non-negative\")\n\t}\n\tif n <= 1 {\n\t\treturn n, nil\n\t}\n\ta, b := 0, 1\n\tfor i := 2; i <= n; i++ {\n\t\ta, b = b, a+b\n\t}\n\treturn b, nil\n}", "edge_case_type": "two", "edge_case_description": "Fibonacci(2) is 1", "test_framework": "testing", "unit_test": "func TestFibTwo(t *testing.T) {\n\tv, _ := Fibonacci(2)\n\tif v != 1 {\n\t\tt.Errorf(\"expected 1, got %d\", v)\n\t}\n}", "difficulty": "easy"} {"id": "beee9e831285dc2e1b412c6bca93d200", "language": "rust", "function_name": "find_max", "function_code": "pub fn find_max(nums: &[i64]) -> Option {\n nums.iter().copied().reduce(i64::max)\n}", "edge_case_type": "empty_slice", "edge_case_description": "empty slice returns None", "test_framework": "rust-test", "unit_test": "#[test]\nfn test_find_max_empty() {\n assert_eq!(find_max(&[]), None);\n}", "difficulty": "easy"} {"id": "22b35ff787ab64456232ad8ae5dc4b95", "language": "python", "function_name": "factorial", "function_code": "def factorial(n: int) -> int:\n if n < 0:\n raise ValueError(\"n must be non-negative\")\n if n == 0:\n return 1\n return n * factorial(n - 1)", "edge_case_type": "two_input", "edge_case_description": "factorial of 2 is 2", "test_framework": "pytest", "unit_test": "def test_factorial_two():\n assert factorial(2) == 2", "difficulty": "medium"} {"id": "0c68ef8c2ed2328856e2c8e239dc61c8", "language": "javascript", "function_name": "pipe", "function_code": "function pipe(...fns) {\n return (x) => fns.reduce((v, f) => f(v), x);\n}", "edge_case_type": "order_matters", "edge_case_description": "order of functions in pipe matters", "test_framework": "jest", "unit_test": "test(\"pipe order matters\", () => {\n const ab = pipe(x => x + 1, x => x * 2);\n const ba = pipe(x => x * 2, x => x + 1);\n expect(ab(3)).not.toBe(ba(3));\n});", "difficulty": "hard"} {"id": "84be0570bdd07e412bcda11ebce6596a", "language": "python", "function_name": "string_to_int", "function_code": "def string_to_int(s: str) -> int | None:\n \"\"\"Parse s as integer, returning None on failure.\"\"\"\n try:\n return int(s.strip())\n except (ValueError, AttributeError):\n return None", "edge_case_type": "mixed_alpha_num", "edge_case_description": "mixed alphanumeric string returns None", "test_framework": "pytest", "unit_test": "def test_str2int_mixed():\n assert string_to_int('12abc') is None", "difficulty": "medium"} {"id": "f0f4800a0f7c9b5bee70041c8825a4e6", "language": "javascript", "function_name": "reverseString", "function_code": "function reverseString(s) {\n return s.split('').reverse().join('');\n}", "edge_case_type": "empty_string", "edge_case_description": "reversing empty string returns empty string", "test_framework": "jest", "unit_test": "test(\"reverseString empty\", () => {\n expect(reverseString(\"\")).toBe(\"\");\n});", "difficulty": "easy"} {"id": "c9fd8ea6c914d41a90e84f393b7b89ab", "language": "javascript", "function_name": "chunk", "function_code": "function chunk(arr, size) {\n if (size <= 0) throw new Error('size must be positive');\n const result = [];\n for (let i = 0; i < arr.length; i += size) {\n result.push(arr.slice(i, i + size));\n }\n return result;\n}", "edge_case_type": "size_zero", "edge_case_description": "chunk size of 0 throws", "test_framework": "jest", "unit_test": "test(\"chunk size zero throws\", () => {\n expect(() => chunk([1, 2], 0)).toThrow();\n});", "difficulty": "medium"} {"id": "dbfd5048f576d86924bad7da80b05051", "language": "javascript", "function_name": "isPalindrome", "function_code": "function isPalindrome(s) {\n const clean = s.toLowerCase().replace(/\\s/g, '');\n return clean === clean.split('').reverse().join('');\n}", "edge_case_type": "case_insensitive", "edge_case_description": "case-insensitive check", "test_framework": "jest", "unit_test": "test(\"isPalindrome case insensitive\", () => {\n expect(isPalindrome(\"Racecar\")).toBe(true);\n});", "difficulty": "medium"} {"id": "5be4052ac3cb712a6d4ea8225900dbc0", "language": "python", "function_name": "find_max", "function_code": "def find_max(nums: list[int]) -> int:\n if not nums:\n raise ValueError(\"List must not be empty\")\n return max(nums)", "edge_case_type": "duplicates", "edge_case_description": "list with duplicate max values returns that max", "test_framework": "pytest", "unit_test": "def test_find_max_duplicates():\n assert find_max([5, 5, 3, 5]) == 5", "difficulty": "medium"} {"id": "74100c03270700dba3ec693e050f6b6d", "language": "java", "function_name": "reverseString", "function_code": "public static String reverseString(String s) {\n return new StringBuilder(s).reverse().toString();\n}", "edge_case_type": "normal_word", "edge_case_description": "normal word reversed correctly", "test_framework": "junit4", "unit_test": "@Test\npublic void testReverseWord() {\n assertEquals(\"olleh\", reverseString(\"hello\"));\n}", "difficulty": "medium"} {"id": "62f0305c30c4c5e972e4a69702a02254", "language": "typescript", "function_name": "omit", "function_code": "export function omit(obj: T, keys: K[]): Omit {\n const result = { ...obj };\n for (const k of keys) delete result[k];\n return result as Omit;\n}", "edge_case_type": "nonexistent_key", "edge_case_description": "omitting key not in object returns unchanged copy", "test_framework": "jest", "unit_test": "test('omit nonexistent', () => {\n const result = omit({a:1} as any, ['z' as any]);\n expect(result).toEqual({a:1});\n});", "difficulty": "medium"} {"id": "057bc92ea08d2f9d23ff25d42c704d72", "language": "python", "function_name": "moving_average", "function_code": "def moving_average(data: list[float], window: int) -> list[float]:\n if window <= 0:\n raise ValueError(\"window must be positive\")\n return [sum(data[i:i+window]) / window for i in range(len(data) - window + 1)]", "edge_case_type": "window_larger_than_data", "edge_case_description": "window larger than data length returns empty list", "test_framework": "pytest", "unit_test": "def test_moving_avg_window_too_large():\n assert moving_average([1.0, 2.0], 5) == []", "difficulty": "medium"} {"id": "a50357228f693b6255d731d5bce70697", "language": "python", "function_name": "string_to_int", "function_code": "def string_to_int(s: str) -> int | None:\n \"\"\"Parse s as integer, returning None on failure.\"\"\"\n try:\n return int(s.strip())\n except (ValueError, AttributeError):\n return None", "edge_case_type": "none_input", "edge_case_description": "None input returns None without raising", "test_framework": "pytest", "unit_test": "def test_str2int_none():\n assert string_to_int(None) is None", "difficulty": "medium"} {"id": "98bf02cea9538d5f25aa06b57228b630", "language": "java", "function_name": "clamp", "function_code": "public static double clamp(double value, double lo, double hi) {\n return Math.max(lo, Math.min(hi, value));\n}", "edge_case_type": "above", "edge_case_description": "value above hi returns hi", "test_framework": "junit4", "unit_test": "@Test\npublic void testClampAbove() {\n assertEquals(10.0, clamp(15, 0, 10), 1e-9);\n}", "difficulty": "medium"} {"id": "6fd199fa4bcb05bd37ccc212f5761be6", "language": "python", "function_name": "divide", "function_code": "def divide(a: float, b: float) -> float:\n \"\"\"Return a divided by b.\"\"\"\n return a / b", "edge_case_type": "float_precision", "edge_case_description": "floating point inputs return correct quotient", "test_framework": "pytest", "unit_test": "def test_divide_float_precision():\n result = divide(1.0, 3.0)\n assert abs(result - 0.3333333333333333) < 1e-10", "difficulty": "medium"} {"id": "59eeff85e6a15ffc8a3428275cad86f3", "language": "java", "function_name": "factorial", "function_code": "public static long factorial(int n) {\n if (n < 0) throw new IllegalArgumentException(\"n must be non-negative\");\n long result = 1;\n for (int i = 2; i <= n; i++) result *= i;\n return result;\n}", "edge_case_type": "ten", "edge_case_description": "factorial(10) is 3628800", "test_framework": "junit4", "unit_test": "@Test\npublic void testFactorialTen() {\n assertEquals(3628800L, factorial(10));\n}", "difficulty": "medium"} {"id": "8e8165aa8e985d07ec0383963f13b94f", "language": "typescript", "function_name": "deepEqual", "function_code": "export function deepEqual(a: unknown, b: unknown): boolean {\n return JSON.stringify(a) === JSON.stringify(b);\n}", "edge_case_type": "null_vs_undefined", "edge_case_description": "null and undefined are not deeply equal", "test_framework": "jest", "unit_test": "test('deepEqual null vs undefined', () => {\n expect(deepEqual(null, undefined)).toBe(false);\n});", "difficulty": "hard"} {"id": "ce36cd4b56e146d8e9544670db8395ce", "language": "python", "function_name": "deep_get", "function_code": "def deep_get(d: dict, *keys, default=None):\n for key in keys:\n if not isinstance(d, dict):\n return default\n d = d.get(key, default)\n return d", "edge_case_type": "missing_key", "edge_case_description": "missing key returns default", "test_framework": "pytest", "unit_test": "def test_deep_get_missing():\n assert deep_get({\"a\": 1}, \"b\") is None", "difficulty": "medium"} {"id": "1df270ba04b215bd06a39fc68bb3aa2f", "language": "python", "function_name": "levenshtein", "function_code": "def levenshtein(s: str, t: str) -> int:\n \"\"\"Compute Levenshtein (edit) distance between s and t.\"\"\"\n m, n = len(s), len(t)\n dp = list(range(n + 1))\n for i in range(1, m + 1):\n prev = dp[0]\n dp[0] = i\n for j in range(1, n + 1):\n tmp = dp[j]\n if s[i-1] == t[j-1]:\n dp[j] = prev\n else:\n dp[j] = 1 + min(prev, dp[j], dp[j-1])\n prev = tmp\n return dp[n]", "edge_case_type": "single_substitution", "edge_case_description": "one character substitution has distance 1", "test_framework": "pytest", "unit_test": "def test_lev_sub():\n assert levenshtein(\"cat\", \"bat\") == 1", "difficulty": "medium"} {"id": "7db93dfdf319adc840c65449e5c2d11b", "language": "python", "function_name": "count_vowels", "function_code": "def count_vowels(s: str) -> int:\n return sum(1 for c in s.lower() if c in \"aeiou\")", "edge_case_type": "numbers_punctuation", "edge_case_description": "digits and punctuation are not counted as vowels", "test_framework": "pytest", "unit_test": "def test_count_vowels_digits():\n assert count_vowels(\"h3ll0!\") == 0", "difficulty": "medium"} {"id": "c791a38e27f3c4b26d4d2d54bee262f7", "language": "rust", "function_name": "clamp", "function_code": "pub fn clamp(value: f64, lo: f64, hi: f64) -> f64 {\n if value < lo { lo } else if value > hi { hi } else { value }\n}", "edge_case_type": "at_lo", "edge_case_description": "value at lo returns lo", "test_framework": "rust-test", "unit_test": "#[test]\nfn test_clamp_at_lo() {\n assert_eq!(clamp(0.0, 0.0, 10.0), 0.0);\n}", "difficulty": "easy"} {"id": "829f30edd436f25373ace690a2f1fa43", "language": "javascript", "function_name": "uniqueBy", "function_code": "function uniqueBy(arr, key) {\n const seen = new Set();\n return arr.filter(item => {\n const k = item[key];\n if (seen.has(k)) return false;\n seen.add(k);\n return true;\n });\n}", "edge_case_type": "empty_array", "edge_case_description": "empty array returns empty", "test_framework": "jest", "unit_test": "test(\"uniqueBy empty\", () => {\n expect(uniqueBy([], \"id\")).toEqual([]);\n});", "difficulty": "easy"} {"id": "2a511df340f0c2d8765640bec66fc5b1", "language": "rust", "function_name": "fibonacci", "function_code": "pub fn fibonacci(n: u64) -> u64 {\n if n <= 1 { return n; }\n let (mut a, mut b) = (0u64, 1u64);\n for _ in 2..=n {\n let c = a + b;\n a = b;\n b = c;\n }\n b\n}", "edge_case_type": "one", "edge_case_description": "fibonacci(1) is 1", "test_framework": "rust-test", "unit_test": "#[test]\nfn test_fib_one() {\n assert_eq!(fibonacci(1), 1);\n}", "difficulty": "easy"} {"id": "6bfefb85c752c9b08756725952d03e9f", "language": "python", "function_name": "Stack", "function_code": "class Stack:\n def __init__(self):\n self._data = []\n\n def push(self, item):\n self._data.append(item)\n\n def pop(self):\n if not self._data:\n raise IndexError(\"pop from empty stack\")\n return self._data.pop()\n\n def peek(self):\n if not self._data:\n raise IndexError(\"peek at empty stack\")\n return self._data[-1]\n\n def is_empty(self):\n return len(self._data) == 0\n\n def size(self):\n return len(self._data)", "edge_case_type": "is_empty_after_push", "edge_case_description": "stack is not empty after push", "test_framework": "pytest", "unit_test": "def test_stack_not_empty_after_push():\n s = Stack()\n s.push(1)\n assert s.is_empty() is False", "difficulty": "easy"} {"id": "f59e9a180e14d8ef9988da82b8a1039e", "language": "python", "function_name": "fizzbuzz", "function_code": "def fizzbuzz(n: int) -> str:\n if n % 15 == 0:\n return \"FizzBuzz\"\n if n % 3 == 0:\n return \"Fizz\"\n if n % 5 == 0:\n return \"Buzz\"\n return str(n)", "edge_case_type": "divisible_by_5", "edge_case_description": "multiple of 5 returns 'Buzz'", "test_framework": "pytest", "unit_test": "def test_fizzbuzz_buzz():\n assert fizzbuzz(10) == \"Buzz\"", "difficulty": "medium"} {"id": "521b204d3ae8b9eabda42732616c4aef", "language": "python", "function_name": "chunk_list", "function_code": "def chunk_list(lst: list, size: int) -> list[list]:\n if size <= 0:\n raise ValueError(\"size must be positive\")\n return [lst[i:i + size] for i in range(0, len(lst), size)]", "edge_case_type": "size_zero", "edge_case_description": "chunk size of 0 raises ValueError", "test_framework": "pytest", "unit_test": "import pytest\n\ndef test_chunk_size_zero():\n with pytest.raises(ValueError):\n chunk_list([1, 2, 3], 0)", "difficulty": "medium"} {"id": "ee86829ff5e534cab3b4511ce015ac69", "language": "rust", "function_name": "is_prime", "function_code": "pub fn is_prime(n: u64) -> bool {\n if n < 2 { return false; }\n if n == 2 { return true; }\n if n % 2 == 0 { return false; }\n let mut i = 3u64;\n while i * i <= n {\n if n % i == 0 { return false; }\n i += 2;\n }\n true\n}", "edge_case_type": "zero", "edge_case_description": "0 is not prime", "test_framework": "rust-test", "unit_test": "#[test]\nfn test_prime_zero() {\n assert!(!is_prime(0));\n}", "difficulty": "easy"} {"id": "9fce1f2e67d05d4901660137cf748fd2", "language": "python", "function_name": "moving_average", "function_code": "def moving_average(data: list[float], window: int) -> list[float]:\n if window <= 0:\n raise ValueError(\"window must be positive\")\n return [sum(data[i:i+window]) / window for i in range(len(data) - window + 1)]", "edge_case_type": "window_negative", "edge_case_description": "negative window raises ValueError", "test_framework": "pytest", "unit_test": "import pytest\n\ndef test_moving_avg_negative_window():\n with pytest.raises(ValueError):\n moving_average([1.0, 2.0], -1)", "difficulty": "medium"} {"id": "811d9ec584cdfef63495c82e17ec9635", "language": "python", "function_name": "divide", "function_code": "def divide(a: float, b: float) -> float:\n \"\"\"Return a divided by b.\"\"\"\n return a / b", "edge_case_type": "zero_numerator", "edge_case_description": "zero divided by any nonzero number is zero", "test_framework": "pytest", "unit_test": "def test_divide_zero_numerator():\n assert divide(0, 5) == 0.0", "difficulty": "medium"} {"id": "f33153eced572d8813d58a3403039cbf", "language": "rust", "function_name": "is_prime", "function_code": "pub fn is_prime(n: u64) -> bool {\n if n < 2 { return false; }\n if n == 2 { return true; }\n if n % 2 == 0 { return false; }\n let mut i = 3u64;\n while i * i <= n {\n if n % i == 0 { return false; }\n i += 2;\n }\n true\n}", "edge_case_type": "two", "edge_case_description": "2 is prime", "test_framework": "rust-test", "unit_test": "#[test]\nfn test_prime_two() {\n assert!(is_prime(2));\n}", "difficulty": "medium"} {"id": "19e7bcbc7b925db29583f111af8563e9", "language": "typescript", "function_name": "parseJSON", "function_code": "export function parseJSON(s: string): T | null {\n try {\n return JSON.parse(s) as T;\n } catch {\n return null;\n }\n}", "edge_case_type": "valid_array", "edge_case_description": "valid JSON array is parsed", "test_framework": "jest", "unit_test": "test('parseJSON valid array', () => {\n expect(parseJSON('[1,2,3]')).toEqual([1,2,3]);\n});", "difficulty": "easy"} {"id": "66572fc65047a6aa6a86641614e6c133", "language": "java", "function_name": "findMax", "function_code": "public static int findMax(int[] arr) {\n if (arr.length == 0) throw new IllegalArgumentException(\"Array is empty\");\n int max = arr[0];\n for (int v : arr) if (v > max) max = v;\n return max;\n}", "edge_case_type": "single_element", "edge_case_description": "single element returns that element", "test_framework": "junit4", "unit_test": "@Test\npublic void testFindMaxSingle() {\n assertEquals(42, findMax(new int[]{42}));\n}", "difficulty": "easy"} {"id": "f9a17f44956d3b9d9b859022ffcdda44", "language": "javascript", "function_name": "pipe", "function_code": "function pipe(...fns) {\n return (x) => fns.reduce((v, f) => f(v), x);\n}", "edge_case_type": "empty_pipeline", "edge_case_description": "empty pipe returns identity", "test_framework": "jest", "unit_test": "test(\"pipe empty\", () => {\n const id = pipe();\n expect(id(5)).toBe(5);\n});", "difficulty": "medium"} {"id": "84ee4d197ab08c809f998c53f212adb5", "language": "javascript", "function_name": "chunk", "function_code": "function chunk(arr, size) {\n if (size <= 0) throw new Error('size must be positive');\n const result = [];\n for (let i = 0; i < arr.length; i += size) {\n result.push(arr.slice(i, i + size));\n }\n return result;\n}", "edge_case_type": "exact_multiple", "edge_case_description": "exact multiple length splits evenly", "test_framework": "jest", "unit_test": "test(\"chunk exact multiple\", () => {\n expect(chunk([1, 2, 3, 4], 2)).toEqual([[1, 2], [3, 4]]);\n});", "difficulty": "easy"} {"id": "922c121d72d4ed5bfbccf336614bd632", "language": "go", "function_name": "ReverseString", "function_code": "func ReverseString(s string) string {\n\trunes := []rune(s)\n\tfor i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {\n\t\trunes[i], runes[j] = runes[j], runes[i]\n\t}\n\treturn string(runes)\n}", "edge_case_type": "empty", "edge_case_description": "empty string returns empty", "test_framework": "testing", "unit_test": "func TestReverseEmpty(t *testing.T) {\n\tif got := ReverseString(\"\"); got != \"\" {\n\t\tt.Errorf(\"expected \"\", got %q\", got)\n\t}\n}", "difficulty": "easy"} {"id": "54a97350c385cf42290e993332c30b71", "language": "go", "function_name": "Clamp", "function_code": "func Clamp(value, lo, hi float64) float64 {\n\tif value < lo {\n\t\treturn lo\n\t}\n\tif value > hi {\n\t\treturn hi\n\t}\n\treturn value\n}", "edge_case_type": "below_lo", "edge_case_description": "value below lo returns lo", "test_framework": "testing", "unit_test": "func TestClampBelow(t *testing.T) {\n\tif got := Clamp(-5, 0, 10); got != 0 {\n\t\tt.Errorf(\"expected 0, got %v\", got)\n\t}\n}", "difficulty": "easy"} {"id": "8179129e8620dcc3835bb3bb33d73fec", "language": "python", "function_name": "is_prime", "function_code": "def is_prime(n: int) -> bool:\n if n < 2:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n return True", "edge_case_type": "negative", "edge_case_description": "negative numbers are not prime", "test_framework": "pytest", "unit_test": "def test_is_prime_negative():\n assert is_prime(-7) is False", "difficulty": "medium"} {"id": "7fd3f7142e6c05e0953d0207f1cade69", "language": "javascript", "function_name": "deepClone", "function_code": "function deepClone(obj) {\n return JSON.parse(JSON.stringify(obj));\n}", "edge_case_type": "primitive", "edge_case_description": "cloning a primitive number returns same value", "test_framework": "jest", "unit_test": "test(\"deepClone primitive\", () => {\n expect(deepClone(42)).toBe(42);\n});", "difficulty": "medium"} {"id": "28d363213762920384c8f131479ac3e5", "language": "python", "function_name": "clamp", "function_code": "def clamp(value: float, lo: float, hi: float) -> float:\n return max(lo, min(hi, value))", "edge_case_type": "lo_equals_hi", "edge_case_description": "when lo equals hi, any value returns that bound", "test_framework": "pytest", "unit_test": "def test_clamp_lo_eq_hi():\n assert clamp(5, 3, 3) == 3", "difficulty": "medium"} {"id": "4dc390e3270fed55734dca7c655817a4", "language": "javascript", "function_name": "findMax", "function_code": "function findMax(arr) {\n if (arr.length === 0) throw new Error('Array is empty');\n return Math.max(...arr);\n}", "edge_case_type": "duplicates", "edge_case_description": "array with duplicates of max returns max", "test_framework": "jest", "unit_test": "test(\"findMax duplicates\", () => {\n expect(findMax([3, 3, 1])).toBe(3);\n});", "difficulty": "medium"} {"id": "79a947226bdeb15336b72fb46bb2c33a", "language": "python", "function_name": "zip_with", "function_code": "def zip_with(fn, a: list, b: list) -> list:\n \"\"\"Apply fn element-wise to paired elements of a and b.\"\"\"\n return [fn(x, y) for x, y in zip(a, b)]", "edge_case_type": "single_element", "edge_case_description": "single element lists return single element", "test_framework": "pytest", "unit_test": "def test_zip_with_single():\n assert zip_with(max, [3], [5]) == [5]", "difficulty": "easy"} {"id": "cbf7c0df91d42e482b01da2bcd2495a7", "language": "python", "function_name": "chunk_list", "function_code": "def chunk_list(lst: list, size: int) -> list[list]:\n if size <= 0:\n raise ValueError(\"size must be positive\")\n return [lst[i:i + size] for i in range(0, len(lst), size)]", "edge_case_type": "size_larger_than_list", "edge_case_description": "chunk size larger than list returns one chunk", "test_framework": "pytest", "unit_test": "def test_chunk_size_larger():\n assert chunk_list([1, 2], 10) == [[1, 2]]", "difficulty": "easy"} {"id": "f8f2d58db9f87c6b00124ebae0cc93b6", "language": "typescript", "function_name": "omit", "function_code": "export function omit(obj: T, keys: K[]): Omit {\n const result = { ...obj };\n for (const k of keys) delete result[k];\n return result as Omit;\n}", "edge_case_type": "all_keys", "edge_case_description": "omitting all keys returns empty object", "test_framework": "jest", "unit_test": "test('omit all keys', () => {\n expect(omit({a:1,b:2}, ['a','b'])).toEqual({});\n});", "difficulty": "medium"} {"id": "b38b6524071ad36e6636bd243c72c34f", "language": "rust", "function_name": "fibonacci", "function_code": "pub fn fibonacci(n: u64) -> u64 {\n if n <= 1 { return n; }\n let (mut a, mut b) = (0u64, 1u64);\n for _ in 2..=n {\n let c = a + b;\n a = b;\n b = c;\n }\n b\n}", "edge_case_type": "zero", "edge_case_description": "fibonacci(0) is 0", "test_framework": "rust-test", "unit_test": "#[test]\nfn test_fib_zero() {\n assert_eq!(fibonacci(0), 0);\n}", "difficulty": "easy"} {"id": "a9a67db15023c73d8f058f9d1514658b", "language": "javascript", "function_name": "findMax", "function_code": "function findMax(arr) {\n if (arr.length === 0) throw new Error('Array is empty');\n return Math.max(...arr);\n}", "edge_case_type": "single_element", "edge_case_description": "single element array returns that element", "test_framework": "jest", "unit_test": "test(\"findMax single element\", () => {\n expect(findMax([42])).toBe(42);\n});", "difficulty": "easy"} {"id": "9111917b13e869bca8630febc206b5d2", "language": "typescript", "function_name": "chunk", "function_code": "export function chunk(arr: T[], size: number): T[][] {\n if (size <= 0) throw new Error('size must be positive');\n const result: T[][] = [];\n for (let i = 0; i < arr.length; i += size) result.push(arr.slice(i, i + size));\n return result;\n}", "edge_case_type": "empty_array", "edge_case_description": "empty array returns empty", "test_framework": "jest", "unit_test": "test('chunk empty', () => {\n expect(chunk([], 3)).toEqual([]);\n});", "difficulty": "easy"} {"id": "db11f4bb1246b5bb787f63000e6f9e1e", "language": "go", "function_name": "Unique", "function_code": "func Unique(nums []int) []int {\n\tseen := make(map[int]bool)\n\tresult := []int{}\n\tfor _, v := range nums {\n\t\tif !seen[v] {\n\t\t\tseen[v] = true\n\t\t\tresult = append(result, v)\n\t\t}\n\t}\n\treturn result\n}", "edge_case_type": "empty_slice", "edge_case_description": "empty slice returns empty", "test_framework": "testing", "unit_test": "func TestUniqueEmpty(t *testing.T) {\n\tresult := Unique([]int{})\n\tif len(result) != 0 {\n\t\tt.Errorf(\"expected empty, got %v\", result)\n\t}\n}", "difficulty": "easy"} {"id": "6544b0f0c1d605611fc063531287426f", "language": "java", "function_name": "factorial", "function_code": "public static long factorial(int n) {\n if (n < 0) throw new IllegalArgumentException(\"n must be non-negative\");\n long result = 1;\n for (int i = 2; i <= n; i++) result *= i;\n return result;\n}", "edge_case_type": "one", "edge_case_description": "factorial(1) is 1", "test_framework": "junit4", "unit_test": "@Test\npublic void testFactorialOne() {\n assertEquals(1L, factorial(1));\n}", "difficulty": "easy"} {"id": "c6171c53b84253d1e03389c679181b46", "language": "python", "function_name": "factorial", "function_code": "def factorial(n: int) -> int:\n if n < 0:\n raise ValueError(\"n must be non-negative\")\n if n == 0:\n return 1\n return n * factorial(n - 1)", "edge_case_type": "negative_input", "edge_case_description": "negative input raises ValueError", "test_framework": "pytest", "unit_test": "import pytest\n\ndef test_factorial_negative():\n with pytest.raises(ValueError):\n factorial(-1)", "difficulty": "medium"} {"id": "788dfb9811f1ccf99dcaaaa2a4ce6cfe", "language": "rust", "function_name": "find_max", "function_code": "pub fn find_max(nums: &[i64]) -> Option {\n nums.iter().copied().reduce(i64::max)\n}", "edge_case_type": "all_negative", "edge_case_description": "all negative returns least negative", "test_framework": "rust-test", "unit_test": "#[test]\nfn test_find_max_neg() {\n assert_eq!(find_max(&[-3, -1, -7]), Some(-1));\n}", "difficulty": "medium"} {"id": "7c38372669cab1258c155379a317351d", "language": "python", "function_name": "divide", "function_code": "def divide(a: float, b: float) -> float:\n \"\"\"Return a divided by b.\"\"\"\n return a / b", "edge_case_type": "negative_numerator", "edge_case_description": "negative numerator returns correct negative result", "test_framework": "pytest", "unit_test": "def test_divide_negative_numerator():\n assert divide(-10, 2) == -5.0", "difficulty": "medium"} {"id": "7d2db485c51743d3ad14425af0bebeaf", "language": "python", "function_name": "reverse_string", "function_code": "def reverse_string(s: str) -> str:\n return s[::-1]", "edge_case_type": "whitespace", "edge_case_description": "whitespace characters are preserved in reverse", "test_framework": "pytest", "unit_test": "def test_reverse_whitespace():\n assert reverse_string(\"a b\") == \"b a\"", "difficulty": "medium"} {"id": "f9b9362622345f254d8045ceb46f7b24", "language": "javascript", "function_name": "pipe", "function_code": "function pipe(...fns) {\n return (x) => fns.reduce((v, f) => f(v), x);\n}", "edge_case_type": "single_fn", "edge_case_description": "pipe with single function applies it", "test_framework": "jest", "unit_test": "test(\"pipe single fn\", () => {\n const double = pipe(x => x * 2);\n expect(double(3)).toBe(6);\n});", "difficulty": "easy"} {"id": "ccc73a8e1758e796d4a388ae656eb38b", "language": "rust", "function_name": "count_vowels", "function_code": "pub fn count_vowels(s: &str) -> usize {\n s.chars().filter(|c| \"aeiouAEIOU\".contains(*c)).count()\n}", "edge_case_type": "uppercase", "edge_case_description": "uppercase vowels counted", "test_framework": "rust-test", "unit_test": "#[test]\nfn test_vowels_upper() {\n assert_eq!(count_vowels(\"AEIOU\"), 5);\n}", "difficulty": "medium"} {"id": "465643b4c162f98272969caa5fac2e06", "language": "python", "function_name": "zip_with", "function_code": "def zip_with(fn, a: list, b: list) -> list:\n \"\"\"Apply fn element-wise to paired elements of a and b.\"\"\"\n return [fn(x, y) for x, y in zip(a, b)]", "edge_case_type": "string_fn", "edge_case_description": "string concatenation function applied element-wise", "test_framework": "pytest", "unit_test": "def test_zip_with_strings():\n result = zip_with(lambda x, y: x + y, ['a', 'b'], ['1', '2'])\n assert result == ['a1', 'b2']", "difficulty": "medium"} {"id": "b648cdaff960690b188371d69df13c60", "language": "typescript", "function_name": "pick", "function_code": "export function pick(obj: T, keys: K[]): Pick {\n const result = {} as Pick;\n for (const k of keys) {\n if (k in obj) result[k] = obj[k];\n }\n return result;\n}", "edge_case_type": "does_not_mutate", "edge_case_description": "original object is not mutated", "test_framework": "jest", "unit_test": "test('pick no mutation', () => {\n const orig = {a:1,b:2};\n pick(orig, ['a']);\n expect(orig).toEqual({a:1,b:2});\n});", "difficulty": "hard"} {"id": "34c0c1edeac14352a9b21aad72f48431", "language": "java", "function_name": "wordCount", "function_code": "public static Map wordCount(String text) {\n Map counts = new HashMap<>();\n if (text == null || text.isBlank()) return counts;\n for (String word : text.toLowerCase().split(\"\\\\s+\")) {\n counts.merge(word, 1, Integer::sum);\n }\n return counts;\n}", "edge_case_type": "repeated_word", "edge_case_description": "repeated words count correctly", "test_framework": "junit4", "unit_test": "@Test\npublic void testWordCountRepeated() {\n Map result = wordCount(\"the the the\");\n assertEquals(3, (int)result.get(\"the\"));\n}", "difficulty": "medium"} {"id": "3ee41d19ef99ba63aafed9960947c46b", "language": "python", "function_name": "deep_get", "function_code": "def deep_get(d: dict, *keys, default=None):\n for key in keys:\n if not isinstance(d, dict):\n return default\n d = d.get(key, default)\n return d", "edge_case_type": "nested_miss", "edge_case_description": "intermediate key missing returns default", "test_framework": "pytest", "unit_test": "def test_deep_get_nested_miss():\n d = {\"a\": {\"x\": 1}}\n assert deep_get(d, \"a\", \"b\", \"c\") is None", "difficulty": "hard"} {"id": "296d2e4e0c95d3db642caee1bf8a9d7e", "language": "typescript", "function_name": "flattenDeep", "function_code": "export function flattenDeep(arr: unknown[]): unknown[] {\n const result: unknown[] = [];\n const stack = [...arr];\n while (stack.length) {\n const item = stack.pop();\n if (Array.isArray(item)) {\n stack.push(...item);\n } else {\n result.unshift(item);\n }\n }\n return result;\n}", "edge_case_type": "preserves_primitives", "edge_case_description": "non-array primitives preserved as-is", "test_framework": "jest", "unit_test": "test('flattenDeep primitives', () => {\n expect(flattenDeep([null, undefined, 0, false])).toEqual([null, undefined, 0, false]);\n});", "difficulty": "medium"} {"id": "fd28e545961ed9688deeb06c51e9c8fb", "language": "java", "function_name": "reverseString", "function_code": "public static String reverseString(String s) {\n return new StringBuilder(s).reverse().toString();\n}", "edge_case_type": "empty_string", "edge_case_description": "empty string returns empty string", "test_framework": "junit4", "unit_test": "@Test\npublic void testReverseEmpty() {\n assertEquals(\"\", reverseString(\"\"));\n}", "difficulty": "easy"} {"id": "85e9defdc3637ad5d0a357de16dc322b", "language": "java", "function_name": "isPalindrome", "function_code": "public static boolean isPalindrome(String s) {\n String clean = s.toLowerCase().replaceAll(\"\\\\s\", \"\");\n return clean.equals(new StringBuilder(clean).reverse().toString());\n}", "edge_case_type": "with_spaces", "edge_case_description": "spaces are ignored", "test_framework": "junit4", "unit_test": "@Test\npublic void testPalindromeSpaces() {\n assertTrue(isPalindrome(\"race car\"));\n}", "difficulty": "medium"} {"id": "92ba3ae1cdb2ab13ec8d4c03bdb003a6", "language": "python", "function_name": "deep_get", "function_code": "def deep_get(d: dict, *keys, default=None):\n for key in keys:\n if not isinstance(d, dict):\n return default\n d = d.get(key, default)\n return d", "edge_case_type": "custom_default", "edge_case_description": "custom default is returned on miss", "test_framework": "pytest", "unit_test": "def test_deep_get_custom_default():\n assert deep_get({}, \"missing\", default=-1) == -1", "difficulty": "medium"} {"id": "5b63110bc5253544e51ee82c33a2d9b9", "language": "python", "function_name": "is_palindrome", "function_code": "def is_palindrome(s: str) -> bool:\n s = s.lower().replace(\" \", \"\")\n return s == s[::-1]", "edge_case_type": "not_palindrome", "edge_case_description": "non-palindrome returns False", "test_framework": "pytest", "unit_test": "def test_is_palindrome_false():\n assert is_palindrome(\"hello\") is False", "difficulty": "easy"} {"id": "c00b51c5f67a11b188f04620c69a0376", "language": "python", "function_name": "moving_average", "function_code": "def moving_average(data: list[float], window: int) -> list[float]:\n if window <= 0:\n raise ValueError(\"window must be positive\")\n return [sum(data[i:i+window]) / window for i in range(len(data) - window + 1)]", "edge_case_type": "window_zero", "edge_case_description": "window of 0 raises ValueError", "test_framework": "pytest", "unit_test": "import pytest\n\ndef test_moving_avg_zero_window():\n with pytest.raises(ValueError):\n moving_average([1.0, 2.0], 0)", "difficulty": "medium"} {"id": "747d4dd284ccc27e3676cac3a3abc662", "language": "typescript", "function_name": "parseJSON", "function_code": "export function parseJSON(s: string): T | null {\n try {\n return JSON.parse(s) as T;\n } catch {\n return null;\n }\n}", "edge_case_type": "valid_object", "edge_case_description": "valid object JSON is parsed correctly", "test_framework": "jest", "unit_test": "test('parseJSON valid object', () => {\n expect(parseJSON<{a:number}>('{\"a\":1}')).toEqual({a:1});\n});", "difficulty": "easy"} {"id": "f9af5ee6f1110f6cd6256d206dbbaea5", "language": "java", "function_name": "divide", "function_code": "public static double divide(double a, double b) {\n if (b == 0) throw new ArithmeticException(\"Division by zero\");\n return a / b;\n}", "edge_case_type": "zero_division", "edge_case_description": "b=0 throws ArithmeticException", "test_framework": "junit4", "unit_test": "@Test(expected = ArithmeticException.class)\npublic void testDivideByZero() {\n divide(10, 0);\n}", "difficulty": "medium"} {"id": "7a79c2a8047461b3189b7ef95bf6cdf3", "language": "python", "function_name": "unique_sorted", "function_code": "def unique_sorted(nums: list[int]) -> list[int]:\n return sorted(set(nums))", "edge_case_type": "single_element", "edge_case_description": "single element list returns single element list", "test_framework": "pytest", "unit_test": "def test_unique_sorted_single():\n assert unique_sorted([5]) == [5]", "difficulty": "easy"} {"id": "3e927e39a79f33c9d9bae17d0b89b912", "language": "javascript", "function_name": "isPalindrome", "function_code": "function isPalindrome(s) {\n const clean = s.toLowerCase().replace(/\\s/g, '');\n return clean === clean.split('').reverse().join('');\n}", "edge_case_type": "with_spaces", "edge_case_description": "spaces ignored in palindrome check", "test_framework": "jest", "unit_test": "test(\"isPalindrome spaces\", () => {\n expect(isPalindrome(\"race car\")).toBe(true);\n});", "difficulty": "medium"} {"id": "9829ea3d08f509595b20bceed50b0c31", "language": "python", "function_name": "flatten", "function_code": "def flatten(nested: list) -> list:\n return [item for sublist in nested for item in sublist]", "edge_case_type": "preserves_order", "edge_case_description": "element order is preserved across sublists", "test_framework": "pytest", "unit_test": "def test_flatten_order():\n assert flatten([[3, 1], [2]]) == [3, 1, 2]", "difficulty": "medium"} {"id": "9672323c3424d74b01e5902d59b40191", "language": "go", "function_name": "ReverseString", "function_code": "func ReverseString(s string) string {\n\trunes := []rune(s)\n\tfor i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {\n\t\trunes[i], runes[j] = runes[j], runes[i]\n\t}\n\treturn string(runes)\n}", "edge_case_type": "single_char", "edge_case_description": "single character returns itself", "test_framework": "testing", "unit_test": "func TestReverseSingle(t *testing.T) {\n\tif got := ReverseString(\"z\"); got != \"z\" {\n\t\tt.Errorf(\"expected z, got %q\", got)\n\t}\n}", "difficulty": "easy"} {"id": "37290cb9c1856325ce1efe79bd7d1cef", "language": "python", "function_name": "is_palindrome", "function_code": "def is_palindrome(s: str) -> bool:\n s = s.lower().replace(\" \", \"\")\n return s == s[::-1]", "edge_case_type": "with_spaces", "edge_case_description": "spaces are ignored in palindrome check", "test_framework": "pytest", "unit_test": "def test_is_palindrome_spaces():\n assert is_palindrome(\"race car\") is True", "difficulty": "medium"} {"id": "2b90160572c86bf50fd227a19c81aa20", "language": "rust", "function_name": "clamp", "function_code": "pub fn clamp(value: f64, lo: f64, hi: f64) -> f64 {\n if value < lo { lo } else if value > hi { hi } else { value }\n}", "edge_case_type": "above", "edge_case_description": "value above hi returns hi", "test_framework": "rust-test", "unit_test": "#[test]\nfn test_clamp_above() {\n assert_eq!(clamp(15.0, 0.0, 10.0), 10.0);\n}", "difficulty": "medium"} {"id": "f76ca788f0d92091897260c2cf4b326e", "language": "python", "function_name": "safe_divide", "function_code": "def safe_divide(a: float, b: float) -> float | None:\n if b == 0:\n return None\n return a / b", "edge_case_type": "negative_divisor", "edge_case_description": "negative divisor returns correct signed result", "test_framework": "pytest", "unit_test": "def test_safe_divide_negative_divisor():\n assert safe_divide(9, -3) == -3.0", "difficulty": "medium"} {"id": "b1379f363c48da706c071e70296dfba8", "language": "python", "function_name": "moving_average", "function_code": "def moving_average(data: list[float], window: int) -> list[float]:\n if window <= 0:\n raise ValueError(\"window must be positive\")\n return [sum(data[i:i+window]) / window for i in range(len(data) - window + 1)]", "edge_case_type": "correct_values", "edge_case_description": "standard window-2 moving average is correct", "test_framework": "pytest", "unit_test": "def test_moving_avg_correct():\n result = moving_average([1.0, 2.0, 3.0, 4.0], 2)\n assert result == [1.5, 2.5, 3.5]", "difficulty": "easy"} {"id": "20e66c83b1bcc5b5236efc1ea09c5de5", "language": "typescript", "function_name": "omit", "function_code": "export function omit(obj: T, keys: K[]): Omit {\n const result = { ...obj };\n for (const k of keys) delete result[k];\n return result as Omit;\n}", "edge_case_type": "single_key", "edge_case_description": "omitting one key removes it", "test_framework": "jest", "unit_test": "test('omit single key', () => {\n expect(omit({a:1,b:2}, ['a'])).toEqual({b:2});\n});", "difficulty": "easy"} {"id": "b22d9e8b2865b9fc9ed362dd6a4ecafe", "language": "python", "function_name": "factorial", "function_code": "def factorial(n: int) -> int:\n if n < 0:\n raise ValueError(\"n must be non-negative\")\n if n == 0:\n return 1\n return n * factorial(n - 1)", "edge_case_type": "zero_input", "edge_case_description": "factorial of 0 is 1", "test_framework": "pytest", "unit_test": "def test_factorial_zero():\n assert factorial(0) == 1", "difficulty": "easy"} {"id": "f05b09b7cd139a515843f7bfb36b9539", "language": "javascript", "function_name": "flatten", "function_code": "function flatten(arr) {\n return arr.flat();\n}", "edge_case_type": "preserves_order", "edge_case_description": "flattened order matches nested order", "test_framework": "jest", "unit_test": "test(\"flatten order\", () => {\n expect(flatten([[3, 1], [2]])).toEqual([3, 1, 2]);\n});", "difficulty": "medium"} {"id": "01c2bf5534b85a3b1d1b096ab0c92bb1", "language": "java", "function_name": "wordCount", "function_code": "public static Map wordCount(String text) {\n Map counts = new HashMap<>();\n if (text == null || text.isBlank()) return counts;\n for (String word : text.toLowerCase().split(\"\\\\s+\")) {\n counts.merge(word, 1, Integer::sum);\n }\n return counts;\n}", "edge_case_type": "single_word", "edge_case_description": "single word returns count 1", "test_framework": "junit4", "unit_test": "@Test\npublic void testWordCountSingle() {\n assertEquals(1, (int)wordCount(\"hello\").get(\"hello\"));\n}", "difficulty": "easy"} {"id": "1333a859bd17d461af10c2cf278e855f", "language": "python", "function_name": "merge_sorted", "function_code": "def merge_sorted(a: list[int], b: list[int]) -> list[int]:\n \"\"\"Merge two sorted lists into one sorted list.\"\"\"\n result, i, j = [], 0, 0\n while i < len(a) and j < len(b):\n if a[i] <= b[j]:\n result.append(a[i]); i += 1\n else:\n result.append(b[j]); j += 1\n result.extend(a[i:])\n result.extend(b[j:])\n return result", "edge_case_type": "one_element_each", "edge_case_description": "single element lists merged correctly", "test_framework": "pytest", "unit_test": "def test_merge_single_each():\n assert merge_sorted([2], [1]) == [1, 2]", "difficulty": "easy"} {"id": "db22a2119fd1cad5c5d6773a42c322b0", "language": "python", "function_name": "binary_search", "function_code": "def binary_search(arr: list[int], target: int) -> int:\n lo, hi = 0, len(arr) - 1\n while lo <= hi:\n mid = (lo + hi) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n lo = mid + 1\n else:\n hi = mid - 1\n return -1", "edge_case_type": "single_element_not_found", "edge_case_description": "single-element array with non-matching target returns -1", "test_framework": "pytest", "unit_test": "def test_binary_search_single_not_found():\n assert binary_search([7], 3) == -1", "difficulty": "medium"} {"id": "efa5871d986e71a14b6affa70a7f054a", "language": "python", "function_name": "cumulative_sum", "function_code": "def cumulative_sum(nums: list[int]) -> list[int]:\n \"\"\"Return running cumulative sum of nums.\"\"\"\n result, total = [], 0\n for n in nums:\n total += n\n result.append(total)\n return result", "edge_case_type": "large_values", "edge_case_description": "large values accumulate without overflow (Python int)", "test_framework": "pytest", "unit_test": "def test_cumsum_large():\n result = cumulative_sum([10**15, 10**15])\n assert result[-1] == 2 * 10**15", "difficulty": "medium"} {"id": "16a2b81c576b14d03370907ed2cd844e", "language": "java", "function_name": "isPalindrome", "function_code": "public static boolean isPalindrome(String s) {\n String clean = s.toLowerCase().replaceAll(\"\\\\s\", \"\");\n return clean.equals(new StringBuilder(clean).reverse().toString());\n}", "edge_case_type": "not_palindrome", "edge_case_description": "non-palindrome returns false", "test_framework": "junit4", "unit_test": "@Test\npublic void testPalindromeNotPalindrome() {\n assertFalse(isPalindrome(\"hello\"));\n}", "difficulty": "easy"} {"id": "293af16d202c91bd852d254e9dc7b0ea", "language": "java", "function_name": "findMax", "function_code": "public static int findMax(int[] arr) {\n if (arr.length == 0) throw new IllegalArgumentException(\"Array is empty\");\n int max = arr[0];\n for (int v : arr) if (v > max) max = v;\n return max;\n}", "edge_case_type": "empty_array", "edge_case_description": "empty array throws IllegalArgumentException", "test_framework": "junit4", "unit_test": "@Test(expected = IllegalArgumentException.class)\npublic void testFindMaxEmpty() {\n findMax(new int[]{});\n}", "difficulty": "easy"} {"id": "a1a14ab2fbda330f58b5b34f78325d0c", "language": "javascript", "function_name": "isPalindrome", "function_code": "function isPalindrome(s) {\n const clean = s.toLowerCase().replace(/\\s/g, '');\n return clean === clean.split('').reverse().join('');\n}", "edge_case_type": "not_palindrome", "edge_case_description": "non-palindrome returns false", "test_framework": "jest", "unit_test": "test(\"isPalindrome false\", () => {\n expect(isPalindrome(\"hello\")).toBe(false);\n});", "difficulty": "easy"} {"id": "d464ce7c78d322ad7df63b369e8f427a", "language": "python", "function_name": "cumulative_sum", "function_code": "def cumulative_sum(nums: list[int]) -> list[int]:\n \"\"\"Return running cumulative sum of nums.\"\"\"\n result, total = [], 0\n for n in nums:\n total += n\n result.append(total)\n return result", "edge_case_type": "single_element", "edge_case_description": "single element is its own cumulative sum", "test_framework": "pytest", "unit_test": "def test_cumsum_single():\n assert cumulative_sum([5]) == [5]", "difficulty": "easy"} {"id": "1a14b71778fa6fec19c8c0f23479d63b", "language": "go", "function_name": "IsPrime", "function_code": "func IsPrime(n int) bool {\n\tif n < 2 {\n\t\treturn false\n\t}\n\tfor i := 2; i*i <= n; i++ {\n\t\tif n%i == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "edge_case_type": "large_prime", "edge_case_description": "97 is prime", "test_framework": "testing", "unit_test": "func TestIsPrimeLarge(t *testing.T) {\n\tif !IsPrime(97) {\n\t\tt.Error(\"97 should be prime\")\n\t}\n}", "difficulty": "medium"} {"id": "fa207c0cee42cd6adef9c5b6435cfca0", "language": "python", "function_name": "group_consecutive", "function_code": "def group_consecutive(nums: list[int]) -> list[list[int]]:\n \"\"\"Group consecutive integers into sublists.\"\"\"\n if not nums:\n return []\n groups, current = [[nums[0]]], [nums[0]]\n for n in nums[1:]:\n if n == current[-1] + 1:\n current.append(n)\n else:\n groups.append([n])\n current = groups[-1]\n return groups", "edge_case_type": "empty", "edge_case_description": "empty input returns empty", "test_framework": "pytest", "unit_test": "def test_group_consec_empty():\n assert group_consecutive([]) == []", "difficulty": "easy"} {"id": "48ebc78b617e369bde552d9f4242001d", "language": "python", "function_name": "group_consecutive", "function_code": "def group_consecutive(nums: list[int]) -> list[list[int]]:\n \"\"\"Group consecutive integers into sublists.\"\"\"\n if not nums:\n return []\n groups, current = [[nums[0]]], [nums[0]]\n for n in nums[1:]:\n if n == current[-1] + 1:\n current.append(n)\n else:\n groups.append([n])\n current = groups[-1]\n return groups", "edge_case_type": "mixed", "edge_case_description": "mixed consecutive and non-consecutive", "test_framework": "pytest", "unit_test": "def test_group_consec_mixed():\n assert group_consecutive([1, 2, 5, 6, 7, 10]) == [[1, 2], [5, 6, 7], [10]]", "difficulty": "hard"} {"id": "7ab582d1236e00e871efd5486992d5d4", "language": "javascript", "function_name": "throttle", "function_code": "function throttle(fn, interval) {\n let lastTime = 0;\n return (...args) => {\n const now = Date.now();\n if (now - lastTime >= interval) {\n lastTime = now;\n return fn(...args);\n }\n };\n}", "edge_case_type": "fires_immediately", "edge_case_description": "first call fires immediately", "test_framework": "jest", "unit_test": "test(\"throttle fires on first call\", () => {\n jest.useFakeTimers();\n const fn = jest.fn();\n const throttled = throttle(fn, 100);\n throttled();\n expect(fn).toHaveBeenCalledTimes(1);\n jest.useRealTimers();\n});", "difficulty": "medium"} {"id": "608bac29cb17de0dcca6c37600f8dceb", "language": "python", "function_name": "clamp", "function_code": "def clamp(value: float, lo: float, hi: float) -> float:\n return max(lo, min(hi, value))", "edge_case_type": "within_range", "edge_case_description": "value within range returns value unchanged", "test_framework": "pytest", "unit_test": "def test_clamp_within():\n assert clamp(5, 0, 10) == 5", "difficulty": "easy"} {"id": "d30adb61f75fa603d28aebbd160278c0", "language": "go", "function_name": "Fibonacci", "function_code": "func Fibonacci(n int) (int, error) {\n\tif n < 0 {\n\t\treturn 0, errors.New(\"n must be non-negative\")\n\t}\n\tif n <= 1 {\n\t\treturn n, nil\n\t}\n\ta, b := 0, 1\n\tfor i := 2; i <= n; i++ {\n\t\ta, b = b, a+b\n\t}\n\treturn b, nil\n}", "edge_case_type": "ten", "edge_case_description": "Fibonacci(10) is 55", "test_framework": "testing", "unit_test": "func TestFibTen(t *testing.T) {\n\tv, _ := Fibonacci(10)\n\tif v != 55 {\n\t\tt.Errorf(\"expected 55, got %d\", v)\n\t}\n}", "difficulty": "medium"} {"id": "8a3bac0e6761c02be39ee606bd6b2b87", "language": "python", "function_name": "count_vowels", "function_code": "def count_vowels(s: str) -> int:\n return sum(1 for c in s.lower() if c in \"aeiou\")", "edge_case_type": "all_vowels", "edge_case_description": "string of all vowels counts all", "test_framework": "pytest", "unit_test": "def test_count_vowels_all():\n assert count_vowels(\"aeiou\") == 5", "difficulty": "medium"} {"id": "cb8520d52fdeaaa464aea184bd3b9b47", "language": "python", "function_name": "word_count", "function_code": "def word_count(text: str) -> dict[str, int]:\n words = text.lower().split()\n counts: dict[str, int] = {}\n for w in words:\n counts[w] = counts.get(w, 0) + 1\n return counts", "edge_case_type": "extra_spaces", "edge_case_description": "extra whitespace between words is handled", "test_framework": "pytest", "unit_test": "def test_word_count_spaces():\n result = word_count(\"a b a\")\n assert result == {\"a\": 2, \"b\": 1}", "difficulty": "medium"} {"id": "ace3ee455d70d7d995b8e2c476392b9a", "language": "python", "function_name": "is_prime", "function_code": "def is_prime(n: int) -> bool:\n if n < 2:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n return True", "edge_case_type": "one", "edge_case_description": "1 is not prime", "test_framework": "pytest", "unit_test": "def test_is_prime_one():\n assert is_prime(1) is False", "difficulty": "easy"} {"id": "9ce7be085cc5d2082b0e0b88257f38b6", "language": "python", "function_name": "factorial", "function_code": "def factorial(n: int) -> int:\n if n < 0:\n raise ValueError(\"n must be non-negative\")\n if n == 0:\n return 1\n return n * factorial(n - 1)", "edge_case_type": "large_input", "edge_case_description": "factorial of 10 equals 3628800", "test_framework": "pytest", "unit_test": "def test_factorial_large():\n assert factorial(10) == 3628800", "difficulty": "hard"} {"id": "c61b3a2f950577da3df4508fa2c4987f", "language": "python", "function_name": "unique_sorted", "function_code": "def unique_sorted(nums: list[int]) -> list[int]:\n return sorted(set(nums))", "edge_case_type": "all_duplicates", "edge_case_description": "list of identical values returns single-element list", "test_framework": "pytest", "unit_test": "def test_unique_sorted_all_dups():\n assert unique_sorted([7, 7, 7]) == [7]", "difficulty": "medium"} {"id": "1fcbede69a5321cb421cfa3aa5c19474", "language": "python", "function_name": "clamp", "function_code": "def clamp(value: float, lo: float, hi: float) -> float:\n return max(lo, min(hi, value))", "edge_case_type": "below_lo", "edge_case_description": "value below lo returns lo", "test_framework": "pytest", "unit_test": "def test_clamp_below():\n assert clamp(-5, 0, 10) == 0", "difficulty": "easy"} {"id": "29cf79b7c61d738ee6c727cbfac9b6a0", "language": "typescript", "function_name": "parseJSON", "function_code": "export function parseJSON(s: string): T | null {\n try {\n return JSON.parse(s) as T;\n } catch {\n return null;\n }\n}", "edge_case_type": "invalid_json", "edge_case_description": "invalid JSON returns null instead of throwing", "test_framework": "jest", "unit_test": "test('parseJSON invalid returns null', () => {\n expect(parseJSON('not json')).toBeNull();\n});", "difficulty": "medium"} {"id": "5d0c74e9bfc0a9ffdf1072b7762754bb", "language": "python", "function_name": "safe_divide", "function_code": "def safe_divide(a: float, b: float) -> float | None:\n if b == 0:\n return None\n return a / b", "edge_case_type": "both_zero", "edge_case_description": "both a=0 and b=0 returns None", "test_framework": "pytest", "unit_test": "def test_safe_divide_both_zero():\n assert safe_divide(0, 0) is None", "difficulty": "medium"} {"id": "45828e44e2424271e2757ec3bc51a180", "language": "typescript", "function_name": "parseJSON", "function_code": "export function parseJSON(s: string): T | null {\n try {\n return JSON.parse(s) as T;\n } catch {\n return null;\n }\n}", "edge_case_type": "nested_object", "edge_case_description": "deeply nested JSON parses correctly", "test_framework": "jest", "unit_test": "test('parseJSON nested', () => {\n expect(parseJSON('{\"a\":{\"b\":2}}')).toEqual({a:{b:2}});\n});", "difficulty": "medium"} {"id": "c6d21b8f8b8b01a79fc34b74ebce8480", "language": "python", "function_name": "divide", "function_code": "def divide(a: float, b: float) -> float:\n \"\"\"Return a divided by b.\"\"\"\n return a / b", "edge_case_type": "both_negative", "edge_case_description": "both operands negative yields positive result", "test_framework": "pytest", "unit_test": "def test_divide_both_negative():\n assert divide(-6, -3) == 2.0", "difficulty": "medium"} {"id": "81ffe1ce53f01f424f7edf239990c5b5", "language": "go", "function_name": "Fibonacci", "function_code": "func Fibonacci(n int) (int, error) {\n\tif n < 0 {\n\t\treturn 0, errors.New(\"n must be non-negative\")\n\t}\n\tif n <= 1 {\n\t\treturn n, nil\n\t}\n\ta, b := 0, 1\n\tfor i := 2; i <= n; i++ {\n\t\ta, b = b, a+b\n\t}\n\treturn b, nil\n}", "edge_case_type": "zero", "edge_case_description": "Fibonacci(0) is 0", "test_framework": "testing", "unit_test": "func TestFibZero(t *testing.T) {\n\tv, _ := Fibonacci(0)\n\tif v != 0 {\n\t\tt.Errorf(\"expected 0, got %d\", v)\n\t}\n}", "difficulty": "easy"} {"id": "0a30ef0de4187c3a52a3209a389c6804", "language": "go", "function_name": "Fibonacci", "function_code": "func Fibonacci(n int) (int, error) {\n\tif n < 0 {\n\t\treturn 0, errors.New(\"n must be non-negative\")\n\t}\n\tif n <= 1 {\n\t\treturn n, nil\n\t}\n\ta, b := 0, 1\n\tfor i := 2; i <= n; i++ {\n\t\ta, b = b, a+b\n\t}\n\treturn b, nil\n}", "edge_case_type": "negative", "edge_case_description": "negative n returns error", "test_framework": "testing", "unit_test": "func TestFibNegative(t *testing.T) {\n\t_, err := Fibonacci(-1)\n\tif err == nil {\n\t\tt.Error(\"expected error for negative n\")\n\t}\n}", "difficulty": "medium"} {"id": "1ad49284f5dc6e87053022b10a5e986b", "language": "rust", "function_name": "count_vowels", "function_code": "pub fn count_vowels(s: &str) -> usize {\n s.chars().filter(|c| \"aeiouAEIOU\".contains(*c)).count()\n}", "edge_case_type": "all_vowels", "edge_case_description": "all vowel string returns full count", "test_framework": "rust-test", "unit_test": "#[test]\nfn test_vowels_all() {\n assert_eq!(count_vowels(\"aeiou\"), 5);\n}", "difficulty": "medium"} {"id": "1a0d44b16c0c9616b3d8df1340e3e98e", "language": "python", "function_name": "string_to_int", "function_code": "def string_to_int(s: str) -> int | None:\n \"\"\"Parse s as integer, returning None on failure.\"\"\"\n try:\n return int(s.strip())\n except (ValueError, AttributeError):\n return None", "edge_case_type": "valid_positive", "edge_case_description": "valid positive integer string parses correctly", "test_framework": "pytest", "unit_test": "def test_str2int_positive():\n assert string_to_int('42') == 42", "difficulty": "easy"} {"id": "f664a718f054769a7a21de13a6ab135c", "language": "javascript", "function_name": "flatten", "function_code": "function flatten(arr) {\n return arr.flat();\n}", "edge_case_type": "empty_inner", "edge_case_description": "nested empty arrays flatten to empty", "test_framework": "jest", "unit_test": "test(\"flatten empty inner\", () => {\n expect(flatten([[], []])).toEqual([]);\n});", "difficulty": "medium"} {"id": "9a6087c75439ae8d3e4adce59dc554d5", "language": "python", "function_name": "binary_search", "function_code": "def binary_search(arr: list[int], target: int) -> int:\n lo, hi = 0, len(arr) - 1\n while lo <= hi:\n mid = (lo + hi) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n lo = mid + 1\n else:\n hi = mid - 1\n return -1", "edge_case_type": "first_element", "edge_case_description": "target is the first element", "test_framework": "pytest", "unit_test": "def test_binary_search_first():\n assert binary_search([1, 3, 5, 7], 1) == 0", "difficulty": "medium"} {"id": "e90b74d1ba331a8c8f5f833c5a8e331a", "language": "java", "function_name": "binarySearch", "function_code": "public static int binarySearch(int[] arr, int target) {\n int lo = 0, hi = arr.length - 1;\n while (lo <= hi) {\n int mid = (lo + hi) >>> 1;\n if (arr[mid] == target) return mid;\n else if (arr[mid] < target) lo = mid + 1;\n else hi = mid - 1;\n }\n return -1;\n}", "edge_case_type": "first_element", "edge_case_description": "target at index 0", "test_framework": "junit4", "unit_test": "@Test\npublic void testBSearchFirst() {\n assertEquals(0, binarySearch(new int[]{1,3,5,7}, 1));\n}", "difficulty": "medium"} {"id": "414cc45f7851c1c77bfdc88c47d70c48", "language": "python", "function_name": "safe_divide", "function_code": "def safe_divide(a: float, b: float) -> float | None:\n if b == 0:\n return None\n return a / b", "edge_case_type": "normal_case", "edge_case_description": "normal non-zero division returns correct result", "test_framework": "pytest", "unit_test": "def test_safe_divide_normal():\n assert safe_divide(10, 4) == 2.5", "difficulty": "easy"} {"id": "d61fc166d0910000e417394526077ee4", "language": "python", "function_name": "string_to_int", "function_code": "def string_to_int(s: str) -> int | None:\n \"\"\"Parse s as integer, returning None on failure.\"\"\"\n try:\n return int(s.strip())\n except (ValueError, AttributeError):\n return None", "edge_case_type": "alpha_string", "edge_case_description": "alphabetic string returns None", "test_framework": "pytest", "unit_test": "def test_str2int_alpha():\n assert string_to_int('abc') is None", "difficulty": "easy"} {"id": "d8148aa8292d5b9cbde0f355636fbfaa", "language": "python", "function_name": "unique_sorted", "function_code": "def unique_sorted(nums: list[int]) -> list[int]:\n return sorted(set(nums))", "edge_case_type": "no_duplicates", "edge_case_description": "list with no duplicates returns sorted copy", "test_framework": "pytest", "unit_test": "def test_unique_sorted_no_dups():\n assert unique_sorted([3, 1, 2]) == [1, 2, 3]", "difficulty": "easy"} {"id": "b1ff051a87e604bfe567dbef72a33ea8", "language": "rust", "function_name": "median", "function_code": "pub fn median(mut nums: Vec) -> Option {\n if nums.is_empty() { return None; }\n nums.sort_by(|a, b| a.partial_cmp(b).unwrap());\n let mid = nums.len() / 2;\n if nums.len() % 2 == 1 {\n Some(nums[mid])\n } else {\n Some((nums[mid - 1] + nums[mid]) / 2.0)\n }\n}", "edge_case_type": "single", "edge_case_description": "single element returns that element", "test_framework": "rust-test", "unit_test": "#[test]\nfn test_median_single() {\n assert_eq!(median(vec![7.0]), Some(7.0));\n}", "difficulty": "easy"} {"id": "bb0825a05a8a0cae38ce224e1e7eabe4", "language": "rust", "function_name": "is_prime", "function_code": "pub fn is_prime(n: u64) -> bool {\n if n < 2 { return false; }\n if n == 2 { return true; }\n if n % 2 == 0 { return false; }\n let mut i = 3u64;\n while i * i <= n {\n if n % i == 0 { return false; }\n i += 2;\n }\n true\n}", "edge_case_type": "one", "edge_case_description": "1 is not prime", "test_framework": "rust-test", "unit_test": "#[test]\nfn test_prime_one() {\n assert!(!is_prime(1));\n}", "difficulty": "easy"} {"id": "4fc717f18e2c0780209ee5a0d9276ed2", "language": "rust", "function_name": "fibonacci", "function_code": "pub fn fibonacci(n: u64) -> u64 {\n if n <= 1 { return n; }\n let (mut a, mut b) = (0u64, 1u64);\n for _ in 2..=n {\n let c = a + b;\n a = b;\n b = c;\n }\n b\n}", "edge_case_type": "large", "edge_case_description": "fibonacci(20) is 6765", "test_framework": "rust-test", "unit_test": "#[test]\nfn test_fib_large() {\n assert_eq!(fibonacci(20), 6765);\n}", "difficulty": "medium"} {"id": "6fe5fb0e432cdf146e3478fd78ca9128", "language": "javascript", "function_name": "groupBy", "function_code": "function groupBy(arr, key) {\n return arr.reduce((acc, item) => {\n const k = item[key];\n if (!acc[k]) acc[k] = [];\n acc[k].push(item);\n return acc;\n }, {});\n}", "edge_case_type": "preserves_order", "edge_case_description": "items within each group preserve insertion order", "test_framework": "jest", "unit_test": "test(\"groupBy preserves order\", () => {\n const items = [{k:\"a\",i:1},{k:\"b\",i:2},{k:\"a\",i:3}];\n expect(groupBy(items,\"k\").a.map(x=>x.i)).toEqual([1,3]);\n});", "difficulty": "medium"} {"id": "fd41e7c79cb926a4f9a0e7f0c49f8200", "language": "rust", "function_name": "reverse_string", "function_code": "pub fn reverse_string(s: &str) -> String {\n s.chars().rev().collect()\n}", "edge_case_type": "empty", "edge_case_description": "empty string returns empty", "test_framework": "rust-test", "unit_test": "#[test]\nfn test_reverse_empty() {\n assert_eq!(reverse_string(\"\"), \"\");\n}", "difficulty": "easy"} {"id": "9c6811fc65df3f99d8283099fce7d01e", "language": "go", "function_name": "Unique", "function_code": "func Unique(nums []int) []int {\n\tseen := make(map[int]bool)\n\tresult := []int{}\n\tfor _, v := range nums {\n\t\tif !seen[v] {\n\t\t\tseen[v] = true\n\t\t\tresult = append(result, v)\n\t\t}\n\t}\n\treturn result\n}", "edge_case_type": "all_duplicates", "edge_case_description": "all identical values returns single element", "test_framework": "testing", "unit_test": "func TestUniqueAllDups(t *testing.T) {\n\tresult := Unique([]int{5, 5, 5})\n\tif len(result) != 1 || result[0] != 5 {\n\t\tt.Errorf(\"expected [5], got %v\", result)\n\t}\n}", "difficulty": "medium"} {"id": "ca35b9f8e72d1e1ba032522032f91c6f", "language": "rust", "function_name": "count_vowels", "function_code": "pub fn count_vowels(s: &str) -> usize {\n s.chars().filter(|c| \"aeiouAEIOU\".contains(*c)).count()\n}", "edge_case_type": "no_vowels", "edge_case_description": "string with no vowels returns 0", "test_framework": "rust-test", "unit_test": "#[test]\nfn test_vowels_none() {\n assert_eq!(count_vowels(\"rhythm\"), 0);\n}", "difficulty": "medium"} {"id": "4462a1de627923b29ff5fb7ddf5d880e", "language": "go", "function_name": "Clamp", "function_code": "func Clamp(value, lo, hi float64) float64 {\n\tif value < lo {\n\t\treturn lo\n\t}\n\tif value > hi {\n\t\treturn hi\n\t}\n\treturn value\n}", "edge_case_type": "above_hi", "edge_case_description": "value above hi returns hi", "test_framework": "testing", "unit_test": "func TestClampAbove(t *testing.T) {\n\tif got := Clamp(15, 0, 10); got != 10 {\n\t\tt.Errorf(\"expected 10, got %v\", got)\n\t}\n}", "difficulty": "easy"} {"id": "8249b095438206b8351956af411ea302", "language": "typescript", "function_name": "groupBy", "function_code": "export function groupBy(arr: T[], key: keyof T): Record {\n return arr.reduce((acc, item) => {\n const k = String(item[key]);\n if (!acc[k]) acc[k] = [];\n acc[k].push(item);\n return acc;\n }, {} as Record);\n}", "edge_case_type": "empty_array", "edge_case_description": "empty array returns empty object", "test_framework": "jest", "unit_test": "test('groupBy empty', () => {\n expect(groupBy([], 'k')).toEqual({});\n});", "difficulty": "easy"} {"id": "ec7d1b4a446bae406c77db0e4d36c5b3", "language": "python", "function_name": "string_to_int", "function_code": "def string_to_int(s: str) -> int | None:\n \"\"\"Parse s as integer, returning None on failure.\"\"\"\n try:\n return int(s.strip())\n except (ValueError, AttributeError):\n return None", "edge_case_type": "zero_string", "edge_case_description": "'0' parses to 0", "test_framework": "pytest", "unit_test": "def test_str2int_zero():\n assert string_to_int('0') == 0", "difficulty": "easy"} {"id": "22ff92e07bf8869aeb060653f9abb01f", "language": "python", "function_name": "moving_average", "function_code": "def moving_average(data: list[float], window: int) -> list[float]:\n if window <= 0:\n raise ValueError(\"window must be positive\")\n return [sum(data[i:i+window]) / window for i in range(len(data) - window + 1)]", "edge_case_type": "window_one", "edge_case_description": "window of 1 returns original values", "test_framework": "pytest", "unit_test": "def test_moving_avg_window_one():\n assert moving_average([1.0, 2.0, 3.0], 1) == [1.0, 2.0, 3.0]", "difficulty": "easy"} {"id": "8c0d5b370f2e0699baf728f347508232", "language": "python", "function_name": "safe_divide", "function_code": "def safe_divide(a: float, b: float) -> float | None:\n if b == 0:\n return None\n return a / b", "edge_case_type": "zero_divisor_none", "edge_case_description": "b=0 returns None instead of raising", "test_framework": "pytest", "unit_test": "def test_safe_divide_zero_returns_none():\n assert safe_divide(10, 0) is None", "difficulty": "medium"} {"id": "015941f880724eddc368ebb6fefe467f", "language": "python", "function_name": "flatten", "function_code": "def flatten(nested: list) -> list:\n return [item for sublist in nested for item in sublist]", "edge_case_type": "empty_inner", "edge_case_description": "list with empty sublists flattens to empty", "test_framework": "pytest", "unit_test": "def test_flatten_empty_inner():\n assert flatten([[], []]) == []", "difficulty": "medium"} {"id": "557a32cea622ec17d9ab899593e67f0b", "language": "rust", "function_name": "fibonacci", "function_code": "pub fn fibonacci(n: u64) -> u64 {\n if n <= 1 { return n; }\n let (mut a, mut b) = (0u64, 1u64);\n for _ in 2..=n {\n let c = a + b;\n a = b;\n b = c;\n }\n b\n}", "edge_case_type": "ten", "edge_case_description": "fibonacci(10) is 55", "test_framework": "rust-test", "unit_test": "#[test]\nfn test_fib_ten() {\n assert_eq!(fibonacci(10), 55);\n}", "difficulty": "medium"} {"id": "42eac298c8c3b288955f7e4f00a6d159", "language": "python", "function_name": "celsius_to_fahrenheit", "function_code": "def celsius_to_fahrenheit(c: float) -> float:\n return c * 9 / 5 + 32", "edge_case_type": "absolute_zero", "edge_case_description": "-273.15\u00b0C converts correctly", "test_framework": "pytest", "unit_test": "def test_celsius_absolute_zero():\n assert abs(celsius_to_fahrenheit(-273.15) - (-459.67)) < 0.01", "difficulty": "hard"} {"id": "98abf843aac661fae994b11fc8c21f59", "language": "python", "function_name": "count_vowels", "function_code": "def count_vowels(s: str) -> int:\n return sum(1 for c in s.lower() if c in \"aeiou\")", "edge_case_type": "empty_string", "edge_case_description": "empty string returns 0", "test_framework": "pytest", "unit_test": "def test_count_vowels_empty():\n assert count_vowels(\"\") == 0", "difficulty": "easy"} {"id": "c8bcd79406e441889259c9f9eaf8aa39", "language": "python", "function_name": "merge_sorted", "function_code": "def merge_sorted(a: list[int], b: list[int]) -> list[int]:\n \"\"\"Merge two sorted lists into one sorted list.\"\"\"\n result, i, j = [], 0, 0\n while i < len(a) and j < len(b):\n if a[i] <= b[j]:\n result.append(a[i]); i += 1\n else:\n result.append(b[j]); j += 1\n result.extend(a[i:])\n result.extend(b[j:])\n return result", "edge_case_type": "interleaved", "edge_case_description": "elements from both lists interleaved correctly", "test_framework": "pytest", "unit_test": "def test_merge_interleaved():\n assert merge_sorted([1, 3, 5], [2, 4, 6]) == [1, 2, 3, 4, 5, 6]", "difficulty": "medium"} {"id": "0faa5903a697f0922b1fde05f9719e86", "language": "python", "function_name": "merge_sorted", "function_code": "def merge_sorted(a: list[int], b: list[int]) -> list[int]:\n \"\"\"Merge two sorted lists into one sorted list.\"\"\"\n result, i, j = [], 0, 0\n while i < len(a) and j < len(b):\n if a[i] <= b[j]:\n result.append(a[i]); i += 1\n else:\n result.append(b[j]); j += 1\n result.extend(a[i:])\n result.extend(b[j:])\n return result", "edge_case_type": "all_same", "edge_case_description": "all identical values remain in order", "test_framework": "pytest", "unit_test": "def test_merge_all_same():\n assert merge_sorted([5, 5], [5, 5]) == [5, 5, 5, 5]", "difficulty": "easy"} {"id": "f4dd409c7af57e1a4a15fe3141303ce5", "language": "go", "function_name": "Contains", "function_code": "func Contains(slice []string, target string) bool {\n\tfor _, v := range slice {\n\t\tif v == target {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "edge_case_type": "empty_string_target", "edge_case_description": "empty string as target found if present", "test_framework": "testing", "unit_test": "func TestContainsEmptyTarget(t *testing.T) {\n\tif !Contains([]string{\"\"}, \"\") {\n\t\tt.Error(\"expected true for empty target\")\n\t}\n}", "difficulty": "medium"} {"id": "9a19dbf0e80258dd400525147ab9c21b", "language": "typescript", "function_name": "flattenDeep", "function_code": "export function flattenDeep(arr: unknown[]): unknown[] {\n const result: unknown[] = [];\n const stack = [...arr];\n while (stack.length) {\n const item = stack.pop();\n if (Array.isArray(item)) {\n stack.push(...item);\n } else {\n result.unshift(item);\n }\n }\n return result;\n}", "edge_case_type": "one_level", "edge_case_description": "one level of nesting flattened", "test_framework": "jest", "unit_test": "test('flattenDeep one level', () => {\n expect(flattenDeep([[1,2],[3]])).toEqual([1,2,3]);\n});", "difficulty": "medium"} {"id": "2097763b64a9689f9b467add1b05b385", "language": "python", "function_name": "celsius_to_fahrenheit", "function_code": "def celsius_to_fahrenheit(c: float) -> float:\n return c * 9 / 5 + 32", "edge_case_type": "boiling_point", "edge_case_description": "100\u00b0C is 212\u00b0F", "test_framework": "pytest", "unit_test": "def test_celsius_boiling():\n assert celsius_to_fahrenheit(100) == 212.0", "difficulty": "easy"} {"id": "24879d992524831c9ef2884a0a5ef610", "language": "go", "function_name": "IsPrime", "function_code": "func IsPrime(n int) bool {\n\tif n < 2 {\n\t\treturn false\n\t}\n\tfor i := 2; i*i <= n; i++ {\n\t\tif n%i == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "edge_case_type": "zero", "edge_case_description": "0 is not prime", "test_framework": "testing", "unit_test": "func TestIsPrimeZero(t *testing.T) {\n\tif IsPrime(0) {\n\t\tt.Error(\"0 should not be prime\")\n\t}\n}", "difficulty": "easy"} {"id": "073c3c3e5b3afbdd9c339175121cfaa7", "language": "go", "function_name": "Contains", "function_code": "func Contains(slice []string, target string) bool {\n\tfor _, v := range slice {\n\t\tif v == target {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "edge_case_type": "duplicate_values", "edge_case_description": "slice with duplicates still returns true", "test_framework": "testing", "unit_test": "func TestContainsDuplicates(t *testing.T) {\n\tif !Contains([]string{\"x\", \"x\", \"y\"}, \"x\") {\n\t\tt.Error(\"expected true\")\n\t}\n}", "difficulty": "easy"} {"id": "dd177ef13db6a6e91372a0dfd1145b94", "language": "python", "function_name": "merge_sorted", "function_code": "def merge_sorted(a: list[int], b: list[int]) -> list[int]:\n \"\"\"Merge two sorted lists into one sorted list.\"\"\"\n result, i, j = [], 0, 0\n while i < len(a) and j < len(b):\n if a[i] <= b[j]:\n result.append(a[i]); i += 1\n else:\n result.append(b[j]); j += 1\n result.extend(a[i:])\n result.extend(b[j:])\n return result", "edge_case_type": "first_empty", "edge_case_description": "merging empty first list returns copy of second", "test_framework": "pytest", "unit_test": "def test_merge_first_empty():\n assert merge_sorted([], [1, 2, 3]) == [1, 2, 3]", "difficulty": "easy"} {"id": "e1a09d593c1bd566e85593c93097bba7", "language": "typescript", "function_name": "flattenDeep", "function_code": "export function flattenDeep(arr: unknown[]): unknown[] {\n const result: unknown[] = [];\n const stack = [...arr];\n while (stack.length) {\n const item = stack.pop();\n if (Array.isArray(item)) {\n stack.push(...item);\n } else {\n result.unshift(item);\n }\n }\n return result;\n}", "edge_case_type": "deep_nesting", "edge_case_description": "deeply nested arrays fully flattened", "test_framework": "jest", "unit_test": "test('flattenDeep deep', () => {\n expect(flattenDeep([1,[2,[3,[4]]]])).toEqual([1,2,3,4]);\n});", "difficulty": "hard"} {"id": "c9ea0a4357e061582a8d8b124dfa8971", "language": "python", "function_name": "truncate", "function_code": "def truncate(s: str, max_len: int) -> str:\n if len(s) <= max_len:\n return s\n return s[:max_len] + \"...\"", "edge_case_type": "longer_than_max", "edge_case_description": "string longer than max_len is truncated with ellipsis", "test_framework": "pytest", "unit_test": "def test_truncate_long():\n assert truncate(\"hello world\", 5) == \"hello...\"", "difficulty": "medium"} {"id": "e488d5d2b9a968816179d44aa6018a7b", "language": "python", "function_name": "cumulative_sum", "function_code": "def cumulative_sum(nums: list[int]) -> list[int]:\n \"\"\"Return running cumulative sum of nums.\"\"\"\n result, total = [], 0\n for n in nums:\n total += n\n result.append(total)\n return result", "edge_case_type": "all_zeros", "edge_case_description": "all zeros cumulates to all zeros", "test_framework": "pytest", "unit_test": "def test_cumsum_zeros():\n assert cumulative_sum([0, 0, 0]) == [0, 0, 0]", "difficulty": "easy"} {"id": "62e3c563410296d212debe63d8140546", "language": "javascript", "function_name": "chunk", "function_code": "function chunk(arr, size) {\n if (size <= 0) throw new Error('size must be positive');\n const result = [];\n for (let i = 0; i < arr.length; i += size) {\n result.push(arr.slice(i, i + size));\n }\n return result;\n}", "edge_case_type": "remainder", "edge_case_description": "last chunk smaller when uneven", "test_framework": "jest", "unit_test": "test(\"chunk remainder\", () => {\n expect(chunk([1, 2, 3, 4, 5], 2)).toEqual([[1, 2], [3, 4], [5]]);\n});", "difficulty": "medium"} {"id": "e248469e8a299ed1182563ad61f4a66e", "language": "typescript", "function_name": "chunk", "function_code": "export function chunk(arr: T[], size: number): T[][] {\n if (size <= 0) throw new Error('size must be positive');\n const result: T[][] = [];\n for (let i = 0; i < arr.length; i += size) result.push(arr.slice(i, i + size));\n return result;\n}", "edge_case_type": "exact_multiple", "edge_case_description": "exact multiple splits evenly", "test_framework": "jest", "unit_test": "test('chunk exact', () => {\n expect(chunk([1,2,3,4],2)).toEqual([[1,2],[3,4]]);\n});", "difficulty": "easy"} {"id": "a7b7736e0935388a2d9d1affcc838051", "language": "go", "function_name": "Unique", "function_code": "func Unique(nums []int) []int {\n\tseen := make(map[int]bool)\n\tresult := []int{}\n\tfor _, v := range nums {\n\t\tif !seen[v] {\n\t\t\tseen[v] = true\n\t\t\tresult = append(result, v)\n\t\t}\n\t}\n\treturn result\n}", "edge_case_type": "preserves_first_occurrence", "edge_case_description": "first occurrence of each value is preserved", "test_framework": "testing", "unit_test": "func TestUniquePreservesOrder(t *testing.T) {\n\tresult := Unique([]int{3, 1, 3, 2})\n\tif result[0] != 3 || result[1] != 1 || result[2] != 2 {\n\t\tt.Errorf(\"wrong order: %v\", result)\n\t}\n}", "difficulty": "medium"} {"id": "25abac4c48e2067c2737821ffb88929b", "language": "rust", "function_name": "divide", "function_code": "pub fn divide(a: f64, b: f64) -> Result {\n if b == 0.0 {\n return Err(\"Division by zero\".to_string());\n }\n Ok(a / b)\n}", "edge_case_type": "zero_divisor", "edge_case_description": "b=0.0 returns Err", "test_framework": "rust-test", "unit_test": "#[test]\nfn test_divide_zero() {\n assert!(divide(10.0, 0.0).is_err());\n}", "difficulty": "medium"} {"id": "9fb5e7f5aa3aec75bcde12df8f5325ee", "language": "python", "function_name": "unique_sorted", "function_code": "def unique_sorted(nums: list[int]) -> list[int]:\n return sorted(set(nums))", "edge_case_type": "negative_numbers", "edge_case_description": "negative numbers are sorted correctly", "test_framework": "pytest", "unit_test": "def test_unique_sorted_negatives():\n assert unique_sorted([-3, -1, -1, 0]) == [-3, -1, 0]", "difficulty": "medium"} {"id": "e94c1f0649b78da24c7e95784b54a8f1", "language": "javascript", "function_name": "deepClone", "function_code": "function deepClone(obj) {\n return JSON.parse(JSON.stringify(obj));\n}", "edge_case_type": "array", "edge_case_description": "cloned array is independent", "test_framework": "jest", "unit_test": "test(\"deepClone array\", () => {\n const orig = [1, [2, 3]];\n const clone = deepClone(orig);\n clone[1][0] = 99;\n expect(orig[1][0]).toBe(2);\n});", "difficulty": "medium"} {"id": "871521ec95ebdf7d13f1587dd17fdf59", "language": "python", "function_name": "string_to_int", "function_code": "def string_to_int(s: str) -> int | None:\n \"\"\"Parse s as integer, returning None on failure.\"\"\"\n try:\n return int(s.strip())\n except (ValueError, AttributeError):\n return None", "edge_case_type": "leading_whitespace", "edge_case_description": "leading/trailing whitespace is stripped before parsing", "test_framework": "pytest", "unit_test": "def test_str2int_whitespace():\n assert string_to_int(' 5 ') == 5", "difficulty": "medium"} {"id": "5cbeaa274ce97a33a03bd212061da547", "language": "javascript", "function_name": "throttle", "function_code": "function throttle(fn, interval) {\n let lastTime = 0;\n return (...args) => {\n const now = Date.now();\n if (now - lastTime >= interval) {\n lastTime = now;\n return fn(...args);\n }\n };\n}", "edge_case_type": "blocks_rapid_calls", "edge_case_description": "rapid calls after first are blocked", "test_framework": "jest", "unit_test": "test(\"throttle blocks rapid calls\", () => {\n jest.useFakeTimers();\n const fn = jest.fn();\n const throttled = throttle(fn, 100);\n throttled();\n throttled();\n throttled();\n expect(fn).toHaveBeenCalledTimes(1);\n jest.useRealTimers();\n});", "difficulty": "hard"} {"id": "d4b35a99a324501c0ac23c2663e9e043", "language": "rust", "function_name": "find_max", "function_code": "pub fn find_max(nums: &[i64]) -> Option {\n nums.iter().copied().reduce(i64::max)\n}", "edge_case_type": "duplicates", "edge_case_description": "duplicates of max returned once", "test_framework": "rust-test", "unit_test": "#[test]\nfn test_find_max_dup() {\n assert_eq!(find_max(&[5, 5, 3]), Some(5));\n}", "difficulty": "medium"} {"id": "a180c114f03eac763e97c9e075144282", "language": "javascript", "function_name": "countOccurrences", "function_code": "function countOccurrences(arr, val) {\n return arr.filter(x => x === val).length;\n}", "edge_case_type": "strict_equality", "edge_case_description": "loose equality types not counted (strict ===)", "test_framework": "jest", "unit_test": "test(\"countOccurrences strict type\", () => {\n expect(countOccurrences([1, \"1\", true], 1)).toBe(1);\n});", "difficulty": "hard"} {"id": "e4eda764a6561f4b2fce837ee140d203", "language": "python", "function_name": "group_consecutive", "function_code": "def group_consecutive(nums: list[int]) -> list[list[int]]:\n \"\"\"Group consecutive integers into sublists.\"\"\"\n if not nums:\n return []\n groups, current = [[nums[0]]], [nums[0]]\n for n in nums[1:]:\n if n == current[-1] + 1:\n current.append(n)\n else:\n groups.append([n])\n current = groups[-1]\n return groups", "edge_case_type": "fully_consecutive", "edge_case_description": "fully consecutive range is one group", "test_framework": "pytest", "unit_test": "def test_group_consec_full():\n assert group_consecutive([1, 2, 3, 4]) == [[1, 2, 3, 4]]", "difficulty": "medium"} {"id": "907db742685b6f74b44c8da3a4997671", "language": "python", "function_name": "reverse_string", "function_code": "def reverse_string(s: str) -> str:\n return s[::-1]", "edge_case_type": "single_char", "edge_case_description": "reversing single character returns same character", "test_framework": "pytest", "unit_test": "def test_reverse_single_char():\n assert reverse_string(\"a\") == \"a\"", "difficulty": "easy"} {"id": "0f25adcdde897056909a3dc45aa532fb", "language": "python", "function_name": "zip_with", "function_code": "def zip_with(fn, a: list, b: list) -> list:\n \"\"\"Apply fn element-wise to paired elements of a and b.\"\"\"\n return [fn(x, y) for x, y in zip(a, b)]", "edge_case_type": "empty_lists", "edge_case_description": "both empty returns empty", "test_framework": "pytest", "unit_test": "def test_zip_with_empty():\n assert zip_with(lambda x, y: x + y, [], []) == []", "difficulty": "easy"} {"id": "5e3d55514490facb14f9b25982d6892b", "language": "rust", "function_name": "median", "function_code": "pub fn median(mut nums: Vec) -> Option {\n if nums.is_empty() { return None; }\n nums.sort_by(|a, b| a.partial_cmp(b).unwrap());\n let mid = nums.len() / 2;\n if nums.len() % 2 == 1 {\n Some(nums[mid])\n } else {\n Some((nums[mid - 1] + nums[mid]) / 2.0)\n }\n}", "edge_case_type": "empty", "edge_case_description": "empty vec returns None", "test_framework": "rust-test", "unit_test": "#[test]\nfn test_median_empty() {\n assert_eq!(median(vec![]), None);\n}", "difficulty": "easy"} {"id": "45448cd3256791775adca7252dc97f83", "language": "python", "function_name": "binary_search", "function_code": "def binary_search(arr: list[int], target: int) -> int:\n lo, hi = 0, len(arr) - 1\n while lo <= hi:\n mid = (lo + hi) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n lo = mid + 1\n else:\n hi = mid - 1\n return -1", "edge_case_type": "last_element", "edge_case_description": "target is the last element", "test_framework": "pytest", "unit_test": "def test_binary_search_last():\n assert binary_search([1, 3, 5, 7], 7) == 3", "difficulty": "medium"} {"id": "ec35013083f7aa013b01282e48c38c1e", "language": "java", "function_name": "divide", "function_code": "public static double divide(double a, double b) {\n if (b == 0) throw new ArithmeticException(\"Division by zero\");\n return a / b;\n}", "edge_case_type": "float_inputs", "edge_case_description": "float inputs return correct quotient", "test_framework": "junit4", "unit_test": "@Test\npublic void testDivideFloat() {\n assertEquals(0.25, divide(1.0, 4.0), 1e-9);\n}", "difficulty": "medium"} {"id": "6ece9ce2d0347cdbda6936b788b0d986", "language": "python", "function_name": "divide", "function_code": "def divide(a: float, b: float) -> float:\n \"\"\"Return a divided by b.\"\"\"\n return a / b", "edge_case_type": "identity", "edge_case_description": "dividing by 1 returns the numerator unchanged", "test_framework": "pytest", "unit_test": "def test_divide_by_one():\n assert divide(7, 1) == 7.0", "difficulty": "easy"} {"id": "16d42e8de51cf8adaa6e68220399eb6a", "language": "python", "function_name": "deep_get", "function_code": "def deep_get(d: dict, *keys, default=None):\n for key in keys:\n if not isinstance(d, dict):\n return default\n d = d.get(key, default)\n return d", "edge_case_type": "nested_hit", "edge_case_description": "nested key lookup returns value", "test_framework": "pytest", "unit_test": "def test_deep_get_nested():\n d = {\"a\": {\"b\": {\"c\": 42}}}\n assert deep_get(d, \"a\", \"b\", \"c\") == 42", "difficulty": "medium"} {"id": "d5e39cd3975e2b979ac828c131b54da9", "language": "python", "function_name": "levenshtein", "function_code": "def levenshtein(s: str, t: str) -> int:\n \"\"\"Compute Levenshtein (edit) distance between s and t.\"\"\"\n m, n = len(s), len(t)\n dp = list(range(n + 1))\n for i in range(1, m + 1):\n prev = dp[0]\n dp[0] = i\n for j in range(1, n + 1):\n tmp = dp[j]\n if s[i-1] == t[j-1]:\n dp[j] = prev\n else:\n dp[j] = 1 + min(prev, dp[j], dp[j-1])\n prev = tmp\n return dp[n]", "edge_case_type": "single_insertion", "edge_case_description": "one insertion has distance 1", "test_framework": "pytest", "unit_test": "def test_lev_insert():\n assert levenshtein(\"cat\", \"cart\") == 1", "difficulty": "medium"} {"id": "f31714d4d9225d909a7cb10a8111f87f", "language": "java", "function_name": "binarySearch", "function_code": "public static int binarySearch(int[] arr, int target) {\n int lo = 0, hi = arr.length - 1;\n while (lo <= hi) {\n int mid = (lo + hi) >>> 1;\n if (arr[mid] == target) return mid;\n else if (arr[mid] < target) lo = mid + 1;\n else hi = mid - 1;\n }\n return -1;\n}", "edge_case_type": "single_element_found", "edge_case_description": "single element array, target found", "test_framework": "junit4", "unit_test": "@Test\npublic void testBSearchSingleFound() {\n assertEquals(0, binarySearch(new int[]{42}, 42));\n}", "difficulty": "easy"} {"id": "9375285549ff6c0d753730e3004d62a3", "language": "python", "function_name": "merge_sorted", "function_code": "def merge_sorted(a: list[int], b: list[int]) -> list[int]:\n \"\"\"Merge two sorted lists into one sorted list.\"\"\"\n result, i, j = [], 0, 0\n while i < len(a) and j < len(b):\n if a[i] <= b[j]:\n result.append(a[i]); i += 1\n else:\n result.append(b[j]); j += 1\n result.extend(a[i:])\n result.extend(b[j:])\n return result", "edge_case_type": "duplicate_values", "edge_case_description": "duplicate values across lists are preserved", "test_framework": "pytest", "unit_test": "def test_merge_duplicates():\n assert merge_sorted([1, 2, 2], [2, 3]) == [1, 2, 2, 2, 3]", "difficulty": "medium"} {"id": "25226d72b3303c0e91ed15af7519ea58", "language": "python", "function_name": "clamp", "function_code": "def clamp(value: float, lo: float, hi: float) -> float:\n return max(lo, min(hi, value))", "edge_case_type": "at_lo_boundary", "edge_case_description": "value equal to lo returns lo", "test_framework": "pytest", "unit_test": "def test_clamp_at_lo():\n assert clamp(0, 0, 10) == 0", "difficulty": "easy"} {"id": "90b1a2597934dcf7c4ac01ab98f25cf0", "language": "typescript", "function_name": "pick", "function_code": "export function pick(obj: T, keys: K[]): Pick {\n const result = {} as Pick;\n for (const k of keys) {\n if (k in obj) result[k] = obj[k];\n }\n return result;\n}", "edge_case_type": "subset_keys", "edge_case_description": "picking subset returns only those keys", "test_framework": "jest", "unit_test": "test('pick subset', () => {\n expect(pick({a:1,b:2,c:3}, ['a','c'])).toEqual({a:1,c:3});\n});", "difficulty": "medium"} {"id": "0f2e360a851244c670a51efcd6a7c56e", "language": "typescript", "function_name": "groupBy", "function_code": "export function groupBy(arr: T[], key: keyof T): Record {\n return arr.reduce((acc, item) => {\n const k = String(item[key]);\n if (!acc[k]) acc[k] = [];\n acc[k].push(item);\n return acc;\n }, {} as Record);\n}", "edge_case_type": "single_group", "edge_case_description": "all items share same key", "test_framework": "jest", "unit_test": "test('groupBy single group', () => {\n const items = [{k:'a',v:1},{k:'a',v:2}];\n expect(Object.keys(groupBy(items,'k'))).toEqual(['a']);\n});", "difficulty": "easy"} {"id": "eeb51d882208ba71f581af2bff7ef565", "language": "javascript", "function_name": "chunk", "function_code": "function chunk(arr, size) {\n if (size <= 0) throw new Error('size must be positive');\n const result = [];\n for (let i = 0; i < arr.length; i += size) {\n result.push(arr.slice(i, i + size));\n }\n return result;\n}", "edge_case_type": "empty_array", "edge_case_description": "chunking empty array returns empty", "test_framework": "jest", "unit_test": "test(\"chunk empty\", () => {\n expect(chunk([], 3)).toEqual([]);\n});", "difficulty": "easy"} {"id": "0c2639e6428a21dde5a3060fee6fd5d9", "language": "java", "function_name": "isPalindrome", "function_code": "public static boolean isPalindrome(String s) {\n String clean = s.toLowerCase().replaceAll(\"\\\\s\", \"\");\n return clean.equals(new StringBuilder(clean).reverse().toString());\n}", "edge_case_type": "case_insensitive", "edge_case_description": "palindrome check is case-insensitive", "test_framework": "junit4", "unit_test": "@Test\npublic void testPalindromeCase() {\n assertTrue(isPalindrome(\"Racecar\"));\n}", "difficulty": "medium"} {"id": "a67aac1ec92f90115ec93c3f574f743a", "language": "go", "function_name": "Divide", "function_code": "func Divide(a, b float64) (float64, error) {\n\tif b == 0 {\n\t\treturn 0, errors.New(\"division by zero\")\n\t}\n\treturn a / b, nil\n}", "edge_case_type": "negative_inputs", "edge_case_description": "negative a and positive b returns negative", "test_framework": "testing", "unit_test": "func TestDivideNegative(t *testing.T) {\n\tresult, err := Divide(-10, 2)\n\tif err != nil || result != -5 {\n\t\tt.Errorf(\"expected -5, got %v (err %v)\", result, err)\n\t}\n}", "difficulty": "medium"} {"id": "3f1053f3b861361df91b501e8cb5f6a2", "language": "go", "function_name": "Contains", "function_code": "func Contains(slice []string, target string) bool {\n\tfor _, v := range slice {\n\t\tif v == target {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "edge_case_type": "case_sensitive", "edge_case_description": "search is case-sensitive", "test_framework": "testing", "unit_test": "func TestContainsCaseSensitive(t *testing.T) {\n\tif Contains([]string{\"Hello\"}, \"hello\") {\n\t\tt.Error(\"should be case-sensitive\")\n\t}\n}", "difficulty": "medium"} {"id": "b6f875d6f74b76bef451eb9825e02892", "language": "go", "function_name": "ReverseString", "function_code": "func ReverseString(s string) string {\n\trunes := []rune(s)\n\tfor i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {\n\t\trunes[i], runes[j] = runes[j], runes[i]\n\t}\n\treturn string(runes)\n}", "edge_case_type": "unicode", "edge_case_description": "unicode string reverses correctly by rune", "test_framework": "testing", "unit_test": "func TestReverseUnicode(t *testing.T) {\n\tif got := ReverseString(\"h\u00e9llo\"); got != \"oll\u00e9h\" {\n\t\tt.Errorf(\"expected oll\u00e9h, got %q\", got)\n\t}\n}", "difficulty": "medium"} {"id": "47422181d9c03e5094e6c31f432cdba9", "language": "java", "function_name": "reverseString", "function_code": "public static String reverseString(String s) {\n return new StringBuilder(s).reverse().toString();\n}", "edge_case_type": "single_char", "edge_case_description": "single character returns itself", "test_framework": "junit4", "unit_test": "@Test\npublic void testReverseSingle() {\n assertEquals(\"a\", reverseString(\"a\"));\n}", "difficulty": "easy"} {"id": "e808369e978c7483927a56e8cd7a0d8d", "language": "python", "function_name": "zip_with", "function_code": "def zip_with(fn, a: list, b: list) -> list:\n \"\"\"Apply fn element-wise to paired elements of a and b.\"\"\"\n return [fn(x, y) for x, y in zip(a, b)]", "edge_case_type": "equal_length", "edge_case_description": "equal length lists zipped correctly", "test_framework": "pytest", "unit_test": "def test_zip_with_equal():\n assert zip_with(lambda x, y: x + y, [1, 2, 3], [10, 20, 30]) == [11, 22, 33]", "difficulty": "easy"} {"id": "d79dece388af4084f9d1bbcd562049f8", "language": "javascript", "function_name": "findMax", "function_code": "function findMax(arr) {\n if (arr.length === 0) throw new Error('Array is empty');\n return Math.max(...arr);\n}", "edge_case_type": "empty_array", "edge_case_description": "empty array throws Error", "test_framework": "jest", "unit_test": "test(\"findMax throws on empty\", () => {\n expect(() => findMax([])).toThrow();\n});", "difficulty": "easy"} {"id": "49a557e4816f155045e2a2763be3219e", "language": "python", "function_name": "binary_search", "function_code": "def binary_search(arr: list[int], target: int) -> int:\n lo, hi = 0, len(arr) - 1\n while lo <= hi:\n mid = (lo + hi) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n lo = mid + 1\n else:\n hi = mid - 1\n return -1", "edge_case_type": "empty_array", "edge_case_description": "empty array returns -1", "test_framework": "pytest", "unit_test": "def test_binary_search_empty():\n assert binary_search([], 5) == -1", "difficulty": "easy"} {"id": "872ca1c38b25d22562bf71ddc8d406f7", "language": "rust", "function_name": "clamp", "function_code": "pub fn clamp(value: f64, lo: f64, hi: f64) -> f64 {\n if value < lo { lo } else if value > hi { hi } else { value }\n}", "edge_case_type": "below", "edge_case_description": "value below lo returns lo", "test_framework": "rust-test", "unit_test": "#[test]\nfn test_clamp_below() {\n assert_eq!(clamp(-5.0, 0.0, 10.0), 0.0);\n}", "difficulty": "medium"} {"id": "7fb99daa74e4dc545c58fbed795e742e", "language": "python", "function_name": "gcd", "function_code": "def gcd(a: int, b: int) -> int:\n while b:\n a, b = b, a % b\n return a", "edge_case_type": "common_factor", "edge_case_description": "gcd of 12 and 8 is 4", "test_framework": "pytest", "unit_test": "def test_gcd_common():\n assert gcd(12, 8) == 4", "difficulty": "medium"} {"id": "7665374c24372a340606602bf8875ae8", "language": "javascript", "function_name": "countOccurrences", "function_code": "function countOccurrences(arr, val) {\n return arr.filter(x => x === val).length;\n}", "edge_case_type": "not_present", "edge_case_description": "value not in array returns 0", "test_framework": "jest", "unit_test": "test(\"countOccurrences not present\", () => {\n expect(countOccurrences([1, 2, 3], 9)).toBe(0);\n});", "difficulty": "medium"} {"id": "165467e09074fa0409569cddce811ead", "language": "python", "function_name": "clamp", "function_code": "def clamp(value: float, lo: float, hi: float) -> float:\n return max(lo, min(hi, value))", "edge_case_type": "at_hi_boundary", "edge_case_description": "value equal to hi returns hi", "test_framework": "pytest", "unit_test": "def test_clamp_at_hi():\n assert clamp(10, 0, 10) == 10", "difficulty": "easy"} {"id": "2d7faecaaf0042bba9c8d6244af1d3e7", "language": "go", "function_name": "IsPrime", "function_code": "func IsPrime(n int) bool {\n\tif n < 2 {\n\t\treturn false\n\t}\n\tfor i := 2; i*i <= n; i++ {\n\t\tif n%i == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "edge_case_type": "two", "edge_case_description": "2 is prime", "test_framework": "testing", "unit_test": "func TestIsPrimeTwo(t *testing.T) {\n\tif !IsPrime(2) {\n\t\tt.Error(\"2 should be prime\")\n\t}\n}", "difficulty": "medium"} {"id": "8b1f2c1a0f277475edf3eef6e7eb0088", "language": "javascript", "function_name": "countOccurrences", "function_code": "function countOccurrences(arr, val) {\n return arr.filter(x => x === val).length;\n}", "edge_case_type": "all_match", "edge_case_description": "all elements match returns length", "test_framework": "jest", "unit_test": "test(\"countOccurrences all match\", () => {\n expect(countOccurrences([7, 7, 7], 7)).toBe(3);\n});", "difficulty": "medium"} {"id": "ea9997a82f503c65a38385402b0e1a21", "language": "python", "function_name": "is_palindrome", "function_code": "def is_palindrome(s: str) -> bool:\n s = s.lower().replace(\" \", \"\")\n return s == s[::-1]", "edge_case_type": "empty_string", "edge_case_description": "empty string is a palindrome", "test_framework": "pytest", "unit_test": "def test_is_palindrome_empty():\n assert is_palindrome(\"\") is True", "difficulty": "easy"} {"id": "7dd8d020ae4632f7937c353fd00efd01", "language": "typescript", "function_name": "flattenDeep", "function_code": "export function flattenDeep(arr: unknown[]): unknown[] {\n const result: unknown[] = [];\n const stack = [...arr];\n while (stack.length) {\n const item = stack.pop();\n if (Array.isArray(item)) {\n stack.push(...item);\n } else {\n result.unshift(item);\n }\n }\n return result;\n}", "edge_case_type": "mixed_depth", "edge_case_description": "mixed nesting depths flattened correctly", "test_framework": "jest", "unit_test": "test('flattenDeep mixed', () => {\n expect(flattenDeep([[1],[2,[3]],4])).toEqual([1,2,3,4]);\n});", "difficulty": "hard"} {"id": "cf6f262e6ac42bd49a6fd1de342f3116", "language": "python", "function_name": "cumulative_sum", "function_code": "def cumulative_sum(nums: list[int]) -> list[int]:\n \"\"\"Return running cumulative sum of nums.\"\"\"\n result, total = [], 0\n for n in nums:\n total += n\n result.append(total)\n return result", "edge_case_type": "mixed_sign", "edge_case_description": "mixed positive and negative values", "test_framework": "pytest", "unit_test": "def test_cumsum_mixed():\n assert cumulative_sum([3, -1, 2]) == [3, 2, 4]", "difficulty": "medium"} {"id": "abfded5d961d94f6e099ba95cb0e2732", "language": "javascript", "function_name": "isPalindrome", "function_code": "function isPalindrome(s) {\n const clean = s.toLowerCase().replace(/\\s/g, '');\n return clean === clean.split('').reverse().join('');\n}", "edge_case_type": "empty_string", "edge_case_description": "empty string is palindrome", "test_framework": "jest", "unit_test": "test(\"isPalindrome empty\", () => {\n expect(isPalindrome(\"\")).toBe(true);\n});", "difficulty": "easy"} {"id": "1d5cc4e360b44d3dc7b616af31469103", "language": "python", "function_name": "flatten", "function_code": "def flatten(nested: list) -> list:\n return [item for sublist in nested for item in sublist]", "edge_case_type": "single_level", "edge_case_description": "single sublist is unwrapped", "test_framework": "pytest", "unit_test": "def test_flatten_single():\n assert flatten([[1, 2, 3]]) == [1, 2, 3]", "difficulty": "medium"} {"id": "f38841648668cbfd0db66d9987d2dba5", "language": "python", "function_name": "levenshtein", "function_code": "def levenshtein(s: str, t: str) -> int:\n \"\"\"Compute Levenshtein (edit) distance between s and t.\"\"\"\n m, n = len(s), len(t)\n dp = list(range(n + 1))\n for i in range(1, m + 1):\n prev = dp[0]\n dp[0] = i\n for j in range(1, n + 1):\n tmp = dp[j]\n if s[i-1] == t[j-1]:\n dp[j] = prev\n else:\n dp[j] = 1 + min(prev, dp[j], dp[j-1])\n prev = tmp\n return dp[n]", "edge_case_type": "empty_target", "edge_case_description": "empty target has distance equal to source length", "test_framework": "pytest", "unit_test": "def test_lev_empty_target():\n assert levenshtein(\"abc\", \"\") == 3", "difficulty": "easy"} {"id": "4844ff00bb79b14deb1362bcc6185a98", "language": "go", "function_name": "Contains", "function_code": "func Contains(slice []string, target string) bool {\n\tfor _, v := range slice {\n\t\tif v == target {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "edge_case_type": "element_present", "edge_case_description": "element in slice returns true", "test_framework": "testing", "unit_test": "func TestContainsPresent(t *testing.T) {\n\tif !Contains([]string{\"a\", \"b\", \"c\"}, \"b\") {\n\t\tt.Error(\"expected true\")\n\t}\n}", "difficulty": "easy"} {"id": "2c01e20b2632c2d58a33ec48abfe3dc6", "language": "rust", "function_name": "divide", "function_code": "pub fn divide(a: f64, b: f64) -> Result {\n if b == 0.0 {\n return Err(\"Division by zero\".to_string());\n }\n Ok(a / b)\n}", "edge_case_type": "negative_numerator", "edge_case_description": "negative a returns correct negative", "test_framework": "rust-test", "unit_test": "#[test]\nfn test_divide_negative() {\n assert_eq!(divide(-10.0, 2.0).unwrap(), -5.0);\n}", "difficulty": "medium"} {"id": "c539233b86be0d946569120a4491b644", "language": "go", "function_name": "FindMax", "function_code": "func FindMax(nums []int) (int, error) {\n\tif len(nums) == 0 {\n\t\treturn 0, errors.New(\"empty slice\")\n\t}\n\tmax := nums[0]\n\tfor _, v := range nums[1:] {\n\t\tif v > max {\n\t\t\tmax = v\n\t\t}\n\t}\n\treturn max, nil\n}", "edge_case_type": "single_element", "edge_case_description": "single element slice returns it", "test_framework": "testing", "unit_test": "func TestFindMaxSingle(t *testing.T) {\n\tv, err := FindMax([]int{42})\n\tif err != nil || v != 42 {\n\t\tt.Errorf(\"expected 42, got %v (err %v)\", v, err)\n\t}\n}", "difficulty": "easy"} {"id": "09cd689780a526a4695e24a632c87be5", "language": "python", "function_name": "clamp", "function_code": "def clamp(value: float, lo: float, hi: float) -> float:\n return max(lo, min(hi, value))", "edge_case_type": "above_hi", "edge_case_description": "value above hi returns hi", "test_framework": "pytest", "unit_test": "def test_clamp_above():\n assert clamp(15, 0, 10) == 10", "difficulty": "easy"} {"id": "3fdea5e57a228199823374e060a58d40", "language": "go", "function_name": "IsPrime", "function_code": "func IsPrime(n int) bool {\n\tif n < 2 {\n\t\treturn false\n\t}\n\tfor i := 2; i*i <= n; i++ {\n\t\tif n%i == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "edge_case_type": "negative", "edge_case_description": "negative numbers are not prime", "test_framework": "testing", "unit_test": "func TestIsPrimeNegative(t *testing.T) {\n\tif IsPrime(-5) {\n\t\tt.Error(\"-5 should not be prime\")\n\t}\n}", "difficulty": "medium"} {"id": "413412c9a6a25735b4ece1235b58fb2a", "language": "python", "function_name": "flatten", "function_code": "def flatten(nested: list) -> list:\n return [item for sublist in nested for item in sublist]", "edge_case_type": "empty_outer", "edge_case_description": "empty outer list returns empty list", "test_framework": "pytest", "unit_test": "def test_flatten_empty():\n assert flatten([]) == []", "difficulty": "easy"} {"id": "050e99e2e9b05ba35ad6da962d09441a", "language": "python", "function_name": "binary_search", "function_code": "def binary_search(arr: list[int], target: int) -> int:\n lo, hi = 0, len(arr) - 1\n while lo <= hi:\n mid = (lo + hi) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n lo = mid + 1\n else:\n hi = mid - 1\n return -1", "edge_case_type": "not_present", "edge_case_description": "target not in array returns -1", "test_framework": "pytest", "unit_test": "def test_binary_search_missing():\n assert binary_search([1, 3, 5, 7], 4) == -1", "difficulty": "medium"} {"id": "bbf6796bc4fb4e7112874e326a4c52c1", "language": "go", "function_name": "ReverseString", "function_code": "func ReverseString(s string) string {\n\trunes := []rune(s)\n\tfor i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {\n\t\trunes[i], runes[j] = runes[j], runes[i]\n\t}\n\treturn string(runes)\n}", "edge_case_type": "palindrome", "edge_case_description": "palindrome returns itself", "test_framework": "testing", "unit_test": "func TestReversePalindrome(t *testing.T) {\n\tif got := ReverseString(\"racecar\"); got != \"racecar\" {\n\t\tt.Errorf(\"expected racecar, got %q\", got)\n\t}\n}", "difficulty": "easy"} {"id": "d1bb37e0e8c3ddd17b87b1d48c2cb9ae", "language": "javascript", "function_name": "flatten", "function_code": "function flatten(arr) {\n return arr.flat();\n}", "edge_case_type": "empty_outer", "edge_case_description": "empty array returns empty", "test_framework": "jest", "unit_test": "test(\"flatten empty\", () => {\n expect(flatten([])).toEqual([]);\n});", "difficulty": "easy"} {"id": "f78f203b221c18531012614f692446fe", "language": "javascript", "function_name": "clamp", "function_code": "function clamp(value, lo, hi) {\n return Math.max(lo, Math.min(hi, value));\n}", "edge_case_type": "within_range", "edge_case_description": "value within range returned unchanged", "test_framework": "jest", "unit_test": "test(\"clamp within\", () => {\n expect(clamp(5, 0, 10)).toBe(5);\n});", "difficulty": "easy"} {"id": "b5b15267b922585cb048b78bfdb64b25", "language": "javascript", "function_name": "reverseString", "function_code": "function reverseString(s) {\n return s.split('').reverse().join('');\n}", "edge_case_type": "palindrome", "edge_case_description": "palindrome reverses to itself", "test_framework": "jest", "unit_test": "test(\"reverseString palindrome\", () => {\n expect(reverseString(\"racecar\")).toBe(\"racecar\");\n});", "difficulty": "easy"} {"id": "43dd4aaf27a4af72e17b16d80b1905fd", "language": "javascript", "function_name": "reverseString", "function_code": "function reverseString(s) {\n return s.split('').reverse().join('');\n}", "edge_case_type": "single_char", "edge_case_description": "single character returns itself", "test_framework": "jest", "unit_test": "test(\"reverseString single char\", () => {\n expect(reverseString(\"a\")).toBe(\"a\");\n});", "difficulty": "easy"} {"id": "c3af0a358339be5d381fcfd0973762b3", "language": "typescript", "function_name": "retry", "function_code": "export async function retry(fn: () => Promise, times: number): Promise {\n let lastErr: unknown;\n for (let i = 0; i < times; i++) {\n try { return await fn(); } catch (e) { lastErr = e; }\n }\n throw lastErr;\n}", "edge_case_type": "succeeds_first", "edge_case_description": "resolves on first attempt with no retry", "test_framework": "jest", "unit_test": "test('retry success first', async () => {\n const fn = jest.fn().mockResolvedValue(42);\n await expect(retry(fn, 3)).resolves.toBe(42);\n expect(fn).toHaveBeenCalledTimes(1);\n});", "difficulty": "medium"} {"id": "26c40840d570be7ebcc5b30b228ad845", "language": "java", "function_name": "divide", "function_code": "public static double divide(double a, double b) {\n if (b == 0) throw new ArithmeticException(\"Division by zero\");\n return a / b;\n}", "edge_case_type": "zero_numerator", "edge_case_description": "zero numerator returns zero", "test_framework": "junit4", "unit_test": "@Test\npublic void testDivideZeroNumerator() {\n assertEquals(0.0, divide(0, 5), 1e-9);\n}", "difficulty": "medium"} {"id": "9d296ac163634049dcb549d06317d47e", "language": "go", "function_name": "WordCount", "function_code": "func WordCount(s string) map[string]int {\n\tcounts := make(map[string]int)\n\tfor _, w := range strings.Fields(s) {\n\t\tcounts[strings.ToLower(w)]++\n\t}\n\treturn counts\n}", "edge_case_type": "empty_string", "edge_case_description": "empty string returns empty map", "test_framework": "testing", "unit_test": "func TestWordCountEmpty(t *testing.T) {\n\tresult := WordCount(\"\")\n\tif len(result) != 0 {\n\t\tt.Errorf(\"expected empty map, got %v\", result)\n\t}\n}", "difficulty": "easy"} {"id": "cd612069c033509588512cf4df7df540", "language": "javascript", "function_name": "divide", "function_code": "function divide(a, b) {\n if (b === 0) throw new Error('Division by zero');\n return a / b;\n}", "edge_case_type": "zero_division", "edge_case_description": "divisor of zero throws Error", "test_framework": "jest", "unit_test": "test(\"divide throws on zero divisor\", () => {\n expect(() => divide(10, 0)).toThrow(\"Division by zero\");\n});", "difficulty": "medium"} {"id": "509ebbdeb4ffefa1037175f4d3d0c733", "language": "javascript", "function_name": "uniqueBy", "function_code": "function uniqueBy(arr, key) {\n const seen = new Set();\n return arr.filter(item => {\n const k = item[key];\n if (seen.has(k)) return false;\n seen.add(k);\n return true;\n });\n}", "edge_case_type": "preserves_first", "edge_case_description": "first occurrence of duplicate key is kept", "test_framework": "jest", "unit_test": "test(\"uniqueBy preserves first\", () => {\n const items = [{id:\"a\",order:1},{id:\"b\",order:2},{id:\"a\",order:3}];\n const result = uniqueBy(items,\"id\");\n expect(result.find(x=>x.id===\"a\").order).toBe(1);\n});", "difficulty": "medium"} {"id": "352745658cde66b6ee96b16f329e33ff", "language": "python", "function_name": "levenshtein", "function_code": "def levenshtein(s: str, t: str) -> int:\n \"\"\"Compute Levenshtein (edit) distance between s and t.\"\"\"\n m, n = len(s), len(t)\n dp = list(range(n + 1))\n for i in range(1, m + 1):\n prev = dp[0]\n dp[0] = i\n for j in range(1, n + 1):\n tmp = dp[j]\n if s[i-1] == t[j-1]:\n dp[j] = prev\n else:\n dp[j] = 1 + min(prev, dp[j], dp[j-1])\n prev = tmp\n return dp[n]", "edge_case_type": "empty_source", "edge_case_description": "empty source has distance equal to target length", "test_framework": "pytest", "unit_test": "def test_lev_empty_source():\n assert levenshtein(\"\", \"abc\") == 3", "difficulty": "easy"} {"id": "cdf15c8853dca3b4d5b12d9349be982c", "language": "python", "function_name": "find_max", "function_code": "def find_max(nums: list[int]) -> int:\n if not nums:\n raise ValueError(\"List must not be empty\")\n return max(nums)", "edge_case_type": "reverse_sorted", "edge_case_description": "reverse-sorted list returns first element", "test_framework": "pytest", "unit_test": "def test_find_max_reverse_sorted():\n assert find_max([9, 7, 4, 2]) == 9", "difficulty": "medium"} {"id": "d1882b22dfebfab38abd9bcbbf28355c", "language": "go", "function_name": "Divide", "function_code": "func Divide(a, b float64) (float64, error) {\n\tif b == 0 {\n\t\treturn 0, errors.New(\"division by zero\")\n\t}\n\treturn a / b, nil\n}", "edge_case_type": "float_division", "edge_case_description": "float64 division returns correct quotient", "test_framework": "testing", "unit_test": "func TestDivideFloat(t *testing.T) {\n\tresult, _ := Divide(1.0, 4.0)\n\tif result != 0.25 {\n\t\tt.Errorf(\"expected 0.25, got %v\", result)\n\t}\n}", "difficulty": "medium"} {"id": "7680f639ab41c3ef3599ec08bb481371", "language": "python", "function_name": "Stack", "function_code": "class Stack:\n def __init__(self):\n self._data = []\n\n def push(self, item):\n self._data.append(item)\n\n def pop(self):\n if not self._data:\n raise IndexError(\"pop from empty stack\")\n return self._data.pop()\n\n def peek(self):\n if not self._data:\n raise IndexError(\"peek at empty stack\")\n return self._data[-1]\n\n def is_empty(self):\n return len(self._data) == 0\n\n def size(self):\n return len(self._data)", "edge_case_type": "size_tracking", "edge_case_description": "size increases with push and decreases with pop", "test_framework": "pytest", "unit_test": "def test_stack_size():\n s = Stack()\n s.push(1)\n s.push(2)\n assert s.size() == 2\n s.pop()\n assert s.size() == 1", "difficulty": "easy"} {"id": "a169444247537bee1a452c9993c0c76b", "language": "go", "function_name": "Fibonacci", "function_code": "func Fibonacci(n int) (int, error) {\n\tif n < 0 {\n\t\treturn 0, errors.New(\"n must be non-negative\")\n\t}\n\tif n <= 1 {\n\t\treturn n, nil\n\t}\n\ta, b := 0, 1\n\tfor i := 2; i <= n; i++ {\n\t\ta, b = b, a+b\n\t}\n\treturn b, nil\n}", "edge_case_type": "one", "edge_case_description": "Fibonacci(1) is 1", "test_framework": "testing", "unit_test": "func TestFibOne(t *testing.T) {\n\tv, _ := Fibonacci(1)\n\tif v != 1 {\n\t\tt.Errorf(\"expected 1, got %d\", v)\n\t}\n}", "difficulty": "easy"} {"id": "2ef5835e02885c57c55aee97fe30c9a6", "language": "javascript", "function_name": "findMax", "function_code": "function findMax(arr) {\n if (arr.length === 0) throw new Error('Array is empty');\n return Math.max(...arr);\n}", "edge_case_type": "all_negative", "edge_case_description": "array of negatives returns least negative", "test_framework": "jest", "unit_test": "test(\"findMax all negative\", () => {\n expect(findMax([-5, -2, -9])).toBe(-2);\n});", "difficulty": "medium"} {"id": "3a7e65c9fa4670e47cd797a52e2c9cfe", "language": "python", "function_name": "gcd", "function_code": "def gcd(a: int, b: int) -> int:\n while b:\n a, b = b, a % b\n return a", "edge_case_type": "one_is_one", "edge_case_description": "gcd where one operand is 1 returns 1", "test_framework": "pytest", "unit_test": "def test_gcd_with_one():\n assert gcd(100, 1) == 1", "difficulty": "medium"} {"id": "4b65351819fd99e85ed384472eaba425", "language": "javascript", "function_name": "flatten", "function_code": "function flatten(arr) {\n return arr.flat();\n}", "edge_case_type": "mixed_lengths", "edge_case_description": "sublists of varying lengths flatten correctly", "test_framework": "jest", "unit_test": "test(\"flatten mixed\", () => {\n expect(flatten([[1], [2, 3]])).toEqual([1, 2, 3]);\n});", "difficulty": "medium"} {"id": "a6a999fc607e2a48d43ac677814f341f", "language": "python", "function_name": "celsius_to_fahrenheit", "function_code": "def celsius_to_fahrenheit(c: float) -> float:\n return c * 9 / 5 + 32", "edge_case_type": "freezing_point", "edge_case_description": "0\u00b0C is 32\u00b0F", "test_framework": "pytest", "unit_test": "def test_celsius_freezing():\n assert celsius_to_fahrenheit(0) == 32.0", "difficulty": "easy"} {"id": "84439831806dd36f894151b4d7b2538f", "language": "javascript", "function_name": "deepClone", "function_code": "function deepClone(obj) {\n return JSON.parse(JSON.stringify(obj));\n}", "edge_case_type": "undefined_stripped", "edge_case_description": "undefined values are stripped by JSON serialization", "test_framework": "jest", "unit_test": "test(\"deepClone strips undefined\", () => {\n const orig = { a: 1, b: undefined };\n const clone = deepClone(orig);\n expect(clone.b).toBeUndefined();\n expect(Object.keys(clone)).not.toContain(\"b\");\n});", "difficulty": "hard"} {"id": "510cf41397f11ebb369e093ef88d7a58", "language": "typescript", "function_name": "groupBy", "function_code": "export function groupBy(arr: T[], key: keyof T): Record {\n return arr.reduce((acc, item) => {\n const k = String(item[key]);\n if (!acc[k]) acc[k] = [];\n acc[k].push(item);\n return acc;\n }, {} as Record);\n}", "edge_case_type": "multiple_groups", "edge_case_description": "items split into correct groups", "test_framework": "jest", "unit_test": "test('groupBy multiple', () => {\n const items = [{k:'a'},{k:'b'},{k:'a'}];\n expect(groupBy(items,'k').a.length).toBe(2);\n expect(groupBy(items,'k').b.length).toBe(1);\n});", "difficulty": "medium"} {"id": "ae35772627bbc3cd6e14eac5fd3fe5cf", "language": "python", "function_name": "truncate", "function_code": "def truncate(s: str, max_len: int) -> str:\n if len(s) <= max_len:\n return s\n return s[:max_len] + \"...\"", "edge_case_type": "shorter_than_max", "edge_case_description": "string shorter than max_len is returned unchanged", "test_framework": "pytest", "unit_test": "def test_truncate_short():\n assert truncate(\"hi\", 10) == \"hi\"", "difficulty": "easy"} {"id": "afc6a007da74f0a908ca44295f914a3b", "language": "python", "function_name": "word_count", "function_code": "def word_count(text: str) -> dict[str, int]:\n words = text.lower().split()\n counts: dict[str, int] = {}\n for w in words:\n counts[w] = counts.get(w, 0) + 1\n return counts", "edge_case_type": "empty_string", "edge_case_description": "empty string returns empty dict", "test_framework": "pytest", "unit_test": "def test_word_count_empty():\n assert word_count(\"\") == {}", "difficulty": "easy"} {"id": "e29b79d34f88fb4b5bd42798d7cc5734", "language": "javascript", "function_name": "clamp", "function_code": "function clamp(value, lo, hi) {\n return Math.max(lo, Math.min(hi, value));\n}", "edge_case_type": "at_boundary", "edge_case_description": "value exactly at lo or hi boundary", "test_framework": "jest", "unit_test": "test(\"clamp at boundary\", () => {\n expect(clamp(0, 0, 10)).toBe(0);\n expect(clamp(10, 0, 10)).toBe(10);\n});", "difficulty": "easy"} {"id": "5e5f7f5e9d837c5232763866c2ffca94", "language": "python", "function_name": "Stack", "function_code": "class Stack:\n def __init__(self):\n self._data = []\n\n def push(self, item):\n self._data.append(item)\n\n def pop(self):\n if not self._data:\n raise IndexError(\"pop from empty stack\")\n return self._data.pop()\n\n def peek(self):\n if not self._data:\n raise IndexError(\"peek at empty stack\")\n return self._data[-1]\n\n def is_empty(self):\n return len(self._data) == 0\n\n def size(self):\n return len(self._data)", "edge_case_type": "pop_empty", "edge_case_description": "popping from empty stack raises IndexError", "test_framework": "pytest", "unit_test": "import pytest\n\ndef test_stack_pop_empty():\n s = Stack()\n with pytest.raises(IndexError):\n s.pop()", "difficulty": "medium"} {"id": "c5ef8c3a1046f5907e66551f66d447a4", "language": "python", "function_name": "reverse_string", "function_code": "def reverse_string(s: str) -> str:\n return s[::-1]", "edge_case_type": "numeric_string", "edge_case_description": "string of digits is reversed correctly", "test_framework": "pytest", "unit_test": "def test_reverse_numeric_string():\n assert reverse_string(\"12345\") == \"54321\"", "difficulty": "medium"} {"id": "bc2e7913509c06195bad0068350248c0", "language": "go", "function_name": "FindMax", "function_code": "func FindMax(nums []int) (int, error) {\n\tif len(nums) == 0 {\n\t\treturn 0, errors.New(\"empty slice\")\n\t}\n\tmax := nums[0]\n\tfor _, v := range nums[1:] {\n\t\tif v > max {\n\t\t\tmax = v\n\t\t}\n\t}\n\treturn max, nil\n}", "edge_case_type": "all_negative", "edge_case_description": "all negative slice returns least negative", "test_framework": "testing", "unit_test": "func TestFindMaxAllNeg(t *testing.T) {\n\tv, _ := FindMax([]int{-3, -1, -7})\n\tif v != -1 {\n\t\tt.Errorf(\"expected -1, got %v\", v)\n\t}\n}", "difficulty": "medium"} {"id": "f771f62a6446e9308291d8d7ae577933", "language": "go", "function_name": "Contains", "function_code": "func Contains(slice []string, target string) bool {\n\tfor _, v := range slice {\n\t\tif v == target {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "edge_case_type": "single_element_match", "edge_case_description": "single element slice matching target", "test_framework": "testing", "unit_test": "func TestContainsSingleMatch(t *testing.T) {\n\tif !Contains([]string{\"only\"}, \"only\") {\n\t\tt.Error(\"expected true\")\n\t}\n}", "difficulty": "easy"} {"id": "08b0ce9b39ebd0d3a90675a2b421f47a", "language": "go", "function_name": "WordCount", "function_code": "func WordCount(s string) map[string]int {\n\tcounts := make(map[string]int)\n\tfor _, w := range strings.Fields(s) {\n\t\tcounts[strings.ToLower(w)]++\n\t}\n\treturn counts\n}", "edge_case_type": "repeated_word", "edge_case_description": "repeated words counted correctly", "test_framework": "testing", "unit_test": "func TestWordCountRepeated(t *testing.T) {\n\tresult := WordCount(\"the cat sat the cat\")\n\tif result[\"the\"] != 2 || result[\"cat\"] != 2 || result[\"sat\"] != 1 {\n\t\tt.Errorf(\"incorrect counts: %v\", result)\n\t}\n}", "difficulty": "medium"} {"id": "f25ed4c9c9fdda900a97d00083b786c3", "language": "python", "function_name": "truncate", "function_code": "def truncate(s: str, max_len: int) -> str:\n if len(s) <= max_len:\n return s\n return s[:max_len] + \"...\"", "edge_case_type": "exact_length", "edge_case_description": "string at exactly max_len is returned unchanged", "test_framework": "pytest", "unit_test": "def test_truncate_exact():\n assert truncate(\"hello\", 5) == \"hello\"", "difficulty": "easy"} {"id": "bc7a99331ec4a629ce9872a8ee4add13", "language": "rust", "function_name": "reverse_string", "function_code": "pub fn reverse_string(s: &str) -> String {\n s.chars().rev().collect()\n}", "edge_case_type": "single_char", "edge_case_description": "single char returns itself", "test_framework": "rust-test", "unit_test": "#[test]\nfn test_reverse_single() {\n assert_eq!(reverse_string(\"a\"), \"a\");\n}", "difficulty": "easy"} {"id": "aca0eecd065acc7558622674d630b5f5", "language": "java", "function_name": "factorial", "function_code": "public static long factorial(int n) {\n if (n < 0) throw new IllegalArgumentException(\"n must be non-negative\");\n long result = 1;\n for (int i = 2; i <= n; i++) result *= i;\n return result;\n}", "edge_case_type": "negative", "edge_case_description": "negative input throws IllegalArgumentException", "test_framework": "junit4", "unit_test": "@Test(expected = IllegalArgumentException.class)\npublic void testFactorialNegative() {\n factorial(-1);\n}", "difficulty": "medium"} {"id": "6e40b815e918430aa6c9a4da14e94f0b", "language": "python", "function_name": "word_count", "function_code": "def word_count(text: str) -> dict[str, int]:\n words = text.lower().split()\n counts: dict[str, int] = {}\n for w in words:\n counts[w] = counts.get(w, 0) + 1\n return counts", "edge_case_type": "case_insensitive", "edge_case_description": "counting is case-insensitive", "test_framework": "pytest", "unit_test": "def test_word_count_case():\n assert word_count(\"Hello hello HELLO\") == {\"hello\": 3}", "difficulty": "medium"} {"id": "9dde056b5785b48ac9f59972982dd6b3", "language": "python", "function_name": "deep_get", "function_code": "def deep_get(d: dict, *keys, default=None):\n for key in keys:\n if not isinstance(d, dict):\n return default\n d = d.get(key, default)\n return d", "edge_case_type": "non_dict_intermediate", "edge_case_description": "non-dict intermediate value returns default", "test_framework": "pytest", "unit_test": "def test_deep_get_non_dict():\n assert deep_get({\"a\": 42}, \"a\", \"b\") is None", "difficulty": "hard"} {"id": "e3dac4e7c0cdf323bae075d4c8fc70a3", "language": "typescript", "function_name": "parseJSON", "function_code": "export function parseJSON(s: string): T | null {\n try {\n return JSON.parse(s) as T;\n } catch {\n return null;\n }\n}", "edge_case_type": "empty_string", "edge_case_description": "empty string returns null", "test_framework": "jest", "unit_test": "test('parseJSON empty string', () => {\n expect(parseJSON('')).toBeNull();\n});", "difficulty": "easy"} {"id": "2d8f43a28bcd1de29bccfb7264852895", "language": "java", "function_name": "binarySearch", "function_code": "public static int binarySearch(int[] arr, int target) {\n int lo = 0, hi = arr.length - 1;\n while (lo <= hi) {\n int mid = (lo + hi) >>> 1;\n if (arr[mid] == target) return mid;\n else if (arr[mid] < target) lo = mid + 1;\n else hi = mid - 1;\n }\n return -1;\n}", "edge_case_type": "last_element", "edge_case_description": "target at last index", "test_framework": "junit4", "unit_test": "@Test\npublic void testBSearchLast() {\n assertEquals(3, binarySearch(new int[]{1,3,5,7}, 7));\n}", "difficulty": "medium"} {"id": "e4fb266f1f1f09bca4f52248c9369e2a", "language": "python", "function_name": "string_to_int", "function_code": "def string_to_int(s: str) -> int | None:\n \"\"\"Parse s as integer, returning None on failure.\"\"\"\n try:\n return int(s.strip())\n except (ValueError, AttributeError):\n return None", "edge_case_type": "valid_negative", "edge_case_description": "valid negative integer string parses correctly", "test_framework": "pytest", "unit_test": "def test_str2int_negative():\n assert string_to_int('-7') == -7", "difficulty": "easy"} {"id": "319932154bc61ac5f4aaaa58bd19ecbd", "language": "python", "function_name": "cumulative_sum", "function_code": "def cumulative_sum(nums: list[int]) -> list[int]:\n \"\"\"Return running cumulative sum of nums.\"\"\"\n result, total = [], 0\n for n in nums:\n total += n\n result.append(total)\n return result", "edge_case_type": "negative_values", "edge_case_description": "negative values reduce cumulative sum", "test_framework": "pytest", "unit_test": "def test_cumsum_negatives():\n assert cumulative_sum([-1, -2, -3]) == [-1, -3, -6]", "difficulty": "medium"} {"id": "c052dfe0b639068d6dd6033633274f4d", "language": "python", "function_name": "moving_average", "function_code": "def moving_average(data: list[float], window: int) -> list[float]:\n if window <= 0:\n raise ValueError(\"window must be positive\")\n return [sum(data[i:i+window]) / window for i in range(len(data) - window + 1)]", "edge_case_type": "window_equals_length", "edge_case_description": "window equal to data length returns single average", "test_framework": "pytest", "unit_test": "def test_moving_avg_window_eq_length():\n assert moving_average([1.0, 2.0, 3.0], 3) == [2.0]", "difficulty": "hard"} {"id": "18abe4ccb09fe65fff2f759d6442db91", "language": "python", "function_name": "unique_sorted", "function_code": "def unique_sorted(nums: list[int]) -> list[int]:\n return sorted(set(nums))", "edge_case_type": "empty_list", "edge_case_description": "empty list returns empty list", "test_framework": "pytest", "unit_test": "def test_unique_sorted_empty():\n assert unique_sorted([]) == []", "difficulty": "easy"} {"id": "0bd73d9aeee88ea835155d7c34124958", "language": "javascript", "function_name": "deepClone", "function_code": "function deepClone(obj) {\n return JSON.parse(JSON.stringify(obj));\n}", "edge_case_type": "nested_object", "edge_case_description": "cloned nested object is independent of original", "test_framework": "jest", "unit_test": "test(\"deepClone nested independent\", () => {\n const orig = { a: { b: 1 } };\n const clone = deepClone(orig);\n clone.a.b = 99;\n expect(orig.a.b).toBe(1);\n});", "difficulty": "medium"} {"id": "12e8017363ade6e517d9a6105bfee796", "language": "javascript", "function_name": "divide", "function_code": "function divide(a, b) {\n if (b === 0) throw new Error('Division by zero');\n return a / b;\n}", "edge_case_type": "float_result", "edge_case_description": "integer inputs yielding float result", "test_framework": "jest", "unit_test": "test(\"divide yields float\", () => {\n expect(divide(1, 3)).toBeCloseTo(0.3333, 4);\n});", "difficulty": "medium"} {"id": "e4719fcdf09510d27a47b3732a106dd2", "language": "python", "function_name": "count_vowels", "function_code": "def count_vowels(s: str) -> int:\n return sum(1 for c in s.lower() if c in \"aeiou\")", "edge_case_type": "uppercase", "edge_case_description": "uppercase vowels are counted correctly", "test_framework": "pytest", "unit_test": "def test_count_vowels_uppercase():\n assert count_vowels(\"AEIOU\") == 5", "difficulty": "medium"} {"id": "7369fa179b06b19462ae46785d0ae983", "language": "python", "function_name": "string_to_int", "function_code": "def string_to_int(s: str) -> int | None:\n \"\"\"Parse s as integer, returning None on failure.\"\"\"\n try:\n return int(s.strip())\n except (ValueError, AttributeError):\n return None", "edge_case_type": "empty_string", "edge_case_description": "empty string returns None", "test_framework": "pytest", "unit_test": "def test_str2int_empty():\n assert string_to_int('') is None", "difficulty": "easy"} {"id": "5198b0f4ce4a1df177dbec9fdda1c4d3", "language": "javascript", "function_name": "uniqueBy", "function_code": "function uniqueBy(arr, key) {\n const seen = new Set();\n return arr.filter(item => {\n const k = item[key];\n if (seen.has(k)) return false;\n seen.add(k);\n return true;\n });\n}", "edge_case_type": "all_duplicates", "edge_case_description": "all same key returns only first", "test_framework": "jest", "unit_test": "test(\"uniqueBy all dups\", () => {\n const items = [{id:1,v:1},{id:1,v:2},{id:1,v:3}];\n const result = uniqueBy(items,\"id\");\n expect(result.length).toBe(1);\n expect(result[0].v).toBe(1);\n});", "difficulty": "medium"} {"id": "af52282fb2ba3ee22bec095011faec47", "language": "python", "function_name": "fizzbuzz", "function_code": "def fizzbuzz(n: int) -> str:\n if n % 15 == 0:\n return \"FizzBuzz\"\n if n % 3 == 0:\n return \"Fizz\"\n if n % 5 == 0:\n return \"Buzz\"\n return str(n)", "edge_case_type": "divisible_by_3", "edge_case_description": "multiple of 3 returns 'Fizz'", "test_framework": "pytest", "unit_test": "def test_fizzbuzz_fizz():\n assert fizzbuzz(9) == \"Fizz\"", "difficulty": "medium"} {"id": "9711001848155a6ca845c3cc29bcd22d", "language": "javascript", "function_name": "memoize", "function_code": "function memoize(fn) {\n const cache = new Map();\n return (...args) => {\n const key = JSON.stringify(args);\n if (cache.has(key)) return cache.get(key);\n const result = fn(...args);\n cache.set(key, result);\n return result;\n };\n}", "edge_case_type": "different_args", "edge_case_description": "different arguments compute fresh results", "test_framework": "jest", "unit_test": "test(\"memoize different args\", () => {\n let calls = 0;\n const fn = memoize((x) => { calls++; return x * 2; });\n fn(1);\n fn(2);\n expect(calls).toBe(2);\n});", "difficulty": "medium"} {"id": "8739adbe3d3d2d6dcdbbc982da973ba1", "language": "python", "function_name": "levenshtein", "function_code": "def levenshtein(s: str, t: str) -> int:\n \"\"\"Compute Levenshtein (edit) distance between s and t.\"\"\"\n m, n = len(s), len(t)\n dp = list(range(n + 1))\n for i in range(1, m + 1):\n prev = dp[0]\n dp[0] = i\n for j in range(1, n + 1):\n tmp = dp[j]\n if s[i-1] == t[j-1]:\n dp[j] = prev\n else:\n dp[j] = 1 + min(prev, dp[j], dp[j-1])\n prev = tmp\n return dp[n]", "edge_case_type": "prefix_match", "edge_case_description": "one string is a prefix of the other", "test_framework": "pytest", "unit_test": "def test_lev_prefix():\n assert levenshtein(\"abc\", \"abcdef\") == 3", "difficulty": "medium"} {"id": "ea0053cce963a0c961be223f75cd7782", "language": "python", "function_name": "chunk_list", "function_code": "def chunk_list(lst: list, size: int) -> list[list]:\n if size <= 0:\n raise ValueError(\"size must be positive\")\n return [lst[i:i + size] for i in range(0, len(lst), size)]", "edge_case_type": "remainder", "edge_case_description": "last chunk is smaller when list doesn't divide evenly", "test_framework": "pytest", "unit_test": "def test_chunk_remainder():\n assert chunk_list([1, 2, 3, 4, 5], 2) == [[1, 2], [3, 4], [5]]", "difficulty": "medium"} {"id": "53a00c49eb4447c422d15a889490ba73", "language": "python", "function_name": "flatten", "function_code": "def flatten(nested: list) -> list:\n return [item for sublist in nested for item in sublist]", "edge_case_type": "mixed_lengths", "edge_case_description": "sublists of varying lengths flatten correctly", "test_framework": "pytest", "unit_test": "def test_flatten_mixed():\n assert flatten([[1], [2, 3], [4, 5, 6]]) == [1, 2, 3, 4, 5, 6]", "difficulty": "medium"} {"id": "5cccdedd71fa6b4d67b2501217d5324a", "language": "typescript", "function_name": "deepEqual", "function_code": "export function deepEqual(a: unknown, b: unknown): boolean {\n return JSON.stringify(a) === JSON.stringify(b);\n}", "edge_case_type": "nested_equal", "edge_case_description": "deeply nested equal objects", "test_framework": "jest", "unit_test": "test('deepEqual nested', () => {\n expect(deepEqual({a:{b:1}}, {a:{b:1}})).toBe(true);\n});", "difficulty": "medium"} {"id": "f6a2701c5c8157940ade1b630515fcde", "language": "go", "function_name": "Unique", "function_code": "func Unique(nums []int) []int {\n\tseen := make(map[int]bool)\n\tresult := []int{}\n\tfor _, v := range nums {\n\t\tif !seen[v] {\n\t\t\tseen[v] = true\n\t\t\tresult = append(result, v)\n\t\t}\n\t}\n\treturn result\n}", "edge_case_type": "no_duplicates", "edge_case_description": "slice without duplicates returns same elements", "test_framework": "testing", "unit_test": "func TestUniqueNoDups(t *testing.T) {\n\tresult := Unique([]int{1, 2, 3})\n\tif len(result) != 3 {\n\t\tt.Errorf(\"expected len 3, got %v\", result)\n\t}\n}", "difficulty": "easy"} {"id": "8e17512dac91ec811124ce94f0d1ac1a", "language": "rust", "function_name": "median", "function_code": "pub fn median(mut nums: Vec) -> Option {\n if nums.is_empty() { return None; }\n nums.sort_by(|a, b| a.partial_cmp(b).unwrap());\n let mid = nums.len() / 2;\n if nums.len() % 2 == 1 {\n Some(nums[mid])\n } else {\n Some((nums[mid - 1] + nums[mid]) / 2.0)\n }\n}", "edge_case_type": "negative_values", "edge_case_description": "negative values handled correctly", "test_framework": "rust-test", "unit_test": "#[test]\nfn test_median_negative() {\n assert_eq!(median(vec![-3.0, -1.0, -2.0]), Some(-2.0));\n}", "difficulty": "medium"} {"id": "6d7cea1690c18af55dc462b931a24fc4", "language": "javascript", "function_name": "groupBy", "function_code": "function groupBy(arr, key) {\n return arr.reduce((acc, item) => {\n const k = item[key];\n if (!acc[k]) acc[k] = [];\n acc[k].push(item);\n return acc;\n }, {});\n}", "edge_case_type": "missing_key", "edge_case_description": "items missing the group key are grouped under undefined", "test_framework": "jest", "unit_test": "test(\"groupBy missing key\", () => {\n const items = [{a: 1}, {}];\n const result = groupBy(items, \"a\");\n expect(result[1]).toEqual([{a: 1}]);\n expect(result[undefined]).toEqual([{}]);\n});", "difficulty": "medium"} {"id": "837dc67c28c9e6e0ba55f2a833eec43e", "language": "python", "function_name": "levenshtein", "function_code": "def levenshtein(s: str, t: str) -> int:\n \"\"\"Compute Levenshtein (edit) distance between s and t.\"\"\"\n m, n = len(s), len(t)\n dp = list(range(n + 1))\n for i in range(1, m + 1):\n prev = dp[0]\n dp[0] = i\n for j in range(1, n + 1):\n tmp = dp[j]\n if s[i-1] == t[j-1]:\n dp[j] = prev\n else:\n dp[j] = 1 + min(prev, dp[j], dp[j-1])\n prev = tmp\n return dp[n]", "edge_case_type": "identical_strings", "edge_case_description": "identical strings have distance 0", "test_framework": "pytest", "unit_test": "def test_lev_identical():\n assert levenshtein(\"cat\", \"cat\") == 0", "difficulty": "easy"} {"id": "6919806dd5c8344bb365ec74bb72527c", "language": "python", "function_name": "word_count", "function_code": "def word_count(text: str) -> dict[str, int]:\n words = text.lower().split()\n counts: dict[str, int] = {}\n for w in words:\n counts[w] = counts.get(w, 0) + 1\n return counts", "edge_case_type": "single_word", "edge_case_description": "single word returns count of 1", "test_framework": "pytest", "unit_test": "def test_word_count_single():\n assert word_count(\"hello\") == {\"hello\": 1}", "difficulty": "easy"} {"id": "4705cb2d39d4d650999df3c6499a7574", "language": "python", "function_name": "is_prime", "function_code": "def is_prime(n: int) -> bool:\n if n < 2:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n return True", "edge_case_type": "large_prime", "edge_case_description": "large prime number returns True", "test_framework": "pytest", "unit_test": "def test_is_prime_large():\n assert is_prime(97) is True", "difficulty": "medium"} {"id": "f67e3909cb4dbfd863dd190fd9fc9a61", "language": "python", "function_name": "find_max", "function_code": "def find_max(nums: list[int]) -> int:\n if not nums:\n raise ValueError(\"List must not be empty\")\n return max(nums)", "edge_case_type": "empty_list", "edge_case_description": "empty list raises ValueError", "test_framework": "pytest", "unit_test": "import pytest\n\ndef test_find_max_empty():\n with pytest.raises(ValueError):\n find_max([])", "difficulty": "easy"} {"id": "a5f3d102a46461f304dc07ea415a2728", "language": "java", "function_name": "wordCount", "function_code": "public static Map wordCount(String text) {\n Map counts = new HashMap<>();\n if (text == null || text.isBlank()) return counts;\n for (String word : text.toLowerCase().split(\"\\\\s+\")) {\n counts.merge(word, 1, Integer::sum);\n }\n return counts;\n}", "edge_case_type": "case_insensitive", "edge_case_description": "case-insensitive counting", "test_framework": "junit4", "unit_test": "@Test\npublic void testWordCountCase() {\n Map result = wordCount(\"Hello hello HELLO\");\n assertEquals(3, (int)result.get(\"hello\"));\n}", "difficulty": "medium"} {"id": "c467bbff021d7b6e98cf8233b360b1b7", "language": "python", "function_name": "merge_sorted", "function_code": "def merge_sorted(a: list[int], b: list[int]) -> list[int]:\n \"\"\"Merge two sorted lists into one sorted list.\"\"\"\n result, i, j = [], 0, 0\n while i < len(a) and j < len(b):\n if a[i] <= b[j]:\n result.append(a[i]); i += 1\n else:\n result.append(b[j]); j += 1\n result.extend(a[i:])\n result.extend(b[j:])\n return result", "edge_case_type": "negative_values", "edge_case_description": "negative values merged correctly", "test_framework": "pytest", "unit_test": "def test_merge_negatives():\n assert merge_sorted([-3, -1], [-2, 0]) == [-3, -2, -1, 0]", "difficulty": "medium"} {"id": "292f02e21b39c8b67d24180c11f26bcb", "language": "python", "function_name": "count_vowels", "function_code": "def count_vowels(s: str) -> int:\n return sum(1 for c in s.lower() if c in \"aeiou\")", "edge_case_type": "no_vowels", "edge_case_description": "string with no vowels returns 0", "test_framework": "pytest", "unit_test": "def test_count_vowels_none():\n assert count_vowels(\"rhythm\") == 0", "difficulty": "medium"} {"id": "027d815a3bcd10e9205e0220961f49f7", "language": "go", "function_name": "Contains", "function_code": "func Contains(slice []string, target string) bool {\n\tfor _, v := range slice {\n\t\tif v == target {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "edge_case_type": "element_absent", "edge_case_description": "element not in slice returns false", "test_framework": "testing", "unit_test": "func TestContainsAbsent(t *testing.T) {\n\tif Contains([]string{\"a\", \"b\"}, \"z\") {\n\t\tt.Error(\"expected false\")\n\t}\n}", "difficulty": "easy"} {"id": "67b70fb4275086d8703a4d2f03a327f0", "language": "typescript", "function_name": "omit", "function_code": "export function omit(obj: T, keys: K[]): Omit {\n const result = { ...obj };\n for (const k of keys) delete result[k];\n return result as Omit;\n}", "edge_case_type": "empty_keys", "edge_case_description": "omitting no keys returns copy of object", "test_framework": "jest", "unit_test": "test('omit empty keys', () => {\n expect(omit({a:1,b:2}, [])).toEqual({a:1,b:2});\n});", "difficulty": "easy"} {"id": "4eefc30791579f71e5851342f3084724", "language": "rust", "function_name": "count_vowels", "function_code": "pub fn count_vowels(s: &str) -> usize {\n s.chars().filter(|c| \"aeiouAEIOU\".contains(*c)).count()\n}", "edge_case_type": "empty", "edge_case_description": "empty string returns 0", "test_framework": "rust-test", "unit_test": "#[test]\nfn test_vowels_empty() {\n assert_eq!(count_vowels(\"\"), 0);\n}", "difficulty": "easy"} {"id": "2deb3ed2a4eb870eb90410e85a994273", "language": "typescript", "function_name": "pick", "function_code": "export function pick(obj: T, keys: K[]): Pick {\n const result = {} as Pick;\n for (const k of keys) {\n if (k in obj) result[k] = obj[k];\n }\n return result;\n}", "edge_case_type": "nonexistent_key", "edge_case_description": "picking nonexistent key omits it silently", "test_framework": "jest", "unit_test": "test('pick nonexistent', () => {\n const result = pick({a:1} as any, ['z' as any]);\n expect(Object.keys(result)).not.toContain('z');\n});", "difficulty": "medium"} {"id": "68d636ed7535288900361cc3889ab5de", "language": "javascript", "function_name": "clamp", "function_code": "function clamp(value, lo, hi) {\n return Math.max(lo, Math.min(hi, value));\n}", "edge_case_type": "below_lo", "edge_case_description": "value below lo returns lo", "test_framework": "jest", "unit_test": "test(\"clamp below lo\", () => {\n expect(clamp(-5, 0, 10)).toBe(0);\n});", "difficulty": "easy"} {"id": "f7b53a59f17b3ac0d82f2eaa6654ff26", "language": "python", "function_name": "Stack", "function_code": "class Stack:\n def __init__(self):\n self._data = []\n\n def push(self, item):\n self._data.append(item)\n\n def pop(self):\n if not self._data:\n raise IndexError(\"pop from empty stack\")\n return self._data.pop()\n\n def peek(self):\n if not self._data:\n raise IndexError(\"peek at empty stack\")\n return self._data[-1]\n\n def is_empty(self):\n return len(self._data) == 0\n\n def size(self):\n return len(self._data)", "edge_case_type": "is_empty_initial", "edge_case_description": "newly created stack is empty", "test_framework": "pytest", "unit_test": "def test_stack_initially_empty():\n assert Stack().is_empty() is True", "difficulty": "easy"} {"id": "64ebe48f8383354ff01f2412c7742981", "language": "python", "function_name": "fizzbuzz", "function_code": "def fizzbuzz(n: int) -> str:\n if n % 15 == 0:\n return \"FizzBuzz\"\n if n % 3 == 0:\n return \"Fizz\"\n if n % 5 == 0:\n return \"Buzz\"\n return str(n)", "edge_case_type": "divisible_by_15", "edge_case_description": "multiple of 15 returns 'FizzBuzz'", "test_framework": "pytest", "unit_test": "def test_fizzbuzz_fizzbuzz():\n assert fizzbuzz(15) == \"FizzBuzz\"", "difficulty": "medium"} {"id": "f1fe7f40e40d321b6be05b36bbc7ffa3", "language": "go", "function_name": "WordCount", "function_code": "func WordCount(s string) map[string]int {\n\tcounts := make(map[string]int)\n\tfor _, w := range strings.Fields(s) {\n\t\tcounts[strings.ToLower(w)]++\n\t}\n\treturn counts\n}", "edge_case_type": "single_word", "edge_case_description": "single word returns count 1", "test_framework": "testing", "unit_test": "func TestWordCountSingle(t *testing.T) {\n\tresult := WordCount(\"hello\")\n\tif result[\"hello\"] != 1 {\n\t\tt.Errorf(\"expected 1, got %v\", result)\n\t}\n}", "difficulty": "easy"}