Spaces:
Sleeping
Sleeping
vineetshukla.work@gmail.com
feat: add inference.py, openenv.yaml, bug dataset & openai dep for hackathon submission
01620c1 | [ | |
| { | |
| "function_name": "add_numbers", | |
| "buggy_code": "def add_numbers(a, b):\n return a - b", | |
| "correct_code": "def add_numbers(a, b):\n return a + b", | |
| "bug_description": "Uses subtraction instead of addition", | |
| "tests": [ | |
| {"name": "basic addition", "code": "assert add_numbers(2, 3) == 5"}, | |
| {"name": "zero addition", "code": "assert add_numbers(0, 0) == 0"}, | |
| {"name": "negative addition", "code": "assert add_numbers(-1, 1) == 0"} | |
| ] | |
| }, | |
| { | |
| "function_name": "find_max", | |
| "buggy_code": "def find_max(lst):\n if not lst:\n return None\n result = lst[0]\n for x in lst:\n if x < result:\n result = x\n return result", | |
| "correct_code": "def find_max(lst):\n if not lst:\n return None\n result = lst[0]\n for x in lst:\n if x > result:\n result = x\n return result", | |
| "bug_description": "Uses < instead of > (finds minimum instead of maximum)", | |
| "tests": [ | |
| {"name": "basic max", "code": "assert find_max([1, 3, 2]) == 3"}, | |
| {"name": "single element", "code": "assert find_max([5]) == 5"}, | |
| {"name": "negative numbers", "code": "assert find_max([-1, -5, -2]) == -1"}, | |
| {"name": "empty list", "code": "assert find_max([]) is None"} | |
| ] | |
| }, | |
| { | |
| "function_name": "reverse_string", | |
| "buggy_code": "def reverse_string(s):\n return s[1:]", | |
| "correct_code": "def reverse_string(s):\n return s[::-1]", | |
| "bug_description": "Slices from index 1 instead of reversing", | |
| "tests": [ | |
| {"name": "basic reverse", "code": "assert reverse_string(\"hello\") == \"olleh\""}, | |
| {"name": "empty string", "code": "assert reverse_string(\"\") == \"\""}, | |
| {"name": "single char", "code": "assert reverse_string(\"a\") == \"a\""}, | |
| {"name": "palindrome", "code": "assert reverse_string(\"racecar\") == \"racecar\""} | |
| ] | |
| }, | |
| { | |
| "function_name": "fibonacci", | |
| "buggy_code": "def fibonacci(n):\n if n <= 0:\n return 0\n if n == 1:\n return 1\n return fibonacci(n - 1) + fibonacci(n - 3)", | |
| "correct_code": "def fibonacci(n):\n if n <= 0:\n return 0\n if n == 1:\n return 1\n return fibonacci(n - 1) + fibonacci(n - 2)", | |
| "bug_description": "Recursive call uses n-3 instead of n-2", | |
| "tests": [ | |
| {"name": "fib(0)", "code": "assert fibonacci(0) == 0"}, | |
| {"name": "fib(1)", "code": "assert fibonacci(1) == 1"}, | |
| {"name": "fib(5)", "code": "assert fibonacci(5) == 5"}, | |
| {"name": "fib(10)", "code": "assert fibonacci(10) == 55"} | |
| ] | |
| }, | |
| { | |
| "function_name": "count_vowels", | |
| "buggy_code": "def count_vowels(s):\n count = 0\n for c in s:\n if c in 'aeiou':\n count += 1\n return count", | |
| "correct_code": "def count_vowels(s):\n count = 0\n for c in s.lower():\n if c in 'aeiou':\n count += 1\n return count", | |
| "bug_description": "Does not handle uppercase vowels", | |
| "tests": [ | |
| {"name": "lowercase", "code": "assert count_vowels('hello') == 2"}, | |
| {"name": "uppercase", "code": "assert count_vowels('HELLO') == 2"}, | |
| {"name": "mixed case", "code": "assert count_vowels('HeLLo') == 2"}, | |
| {"name": "no vowels", "code": "assert count_vowels('xyz') == 0"} | |
| ] | |
| }, | |
| { | |
| "function_name": "is_palindrome", | |
| "buggy_code": "def is_palindrome(s):\n s = s.lower()\n return s == s[::-1]", | |
| "correct_code": "def is_palindrome(s):\n s = ''.join(c for c in s.lower() if c.isalnum())\n return s == s[::-1]", | |
| "bug_description": "Does not strip non-alphanumeric characters before checking", | |
| "tests": [ | |
| {"name": "basic palindrome", "code": "assert is_palindrome('racecar') == True"}, | |
| {"name": "with spaces", "code": "assert is_palindrome('race car') == False"}, | |
| {"name": "with punctuation", "code": "assert is_palindrome('A man, a plan, a canal: Panama') == True"}, | |
| {"name": "not palindrome", "code": "assert is_palindrome('hello') == False"} | |
| ] | |
| }, | |
| { | |
| "function_name": "flatten_list", | |
| "buggy_code": "def flatten_list(lst):\n result = []\n for item in lst:\n if isinstance(item, list):\n result.append(item)\n else:\n result.append(item)\n return result", | |
| "correct_code": "def flatten_list(lst):\n result = []\n for item in lst:\n if isinstance(item, list):\n result.extend(flatten_list(item))\n else:\n result.append(item)\n return result", | |
| "bug_description": "Appends nested lists instead of recursively flattening them", | |
| "tests": [ | |
| {"name": "nested", "code": "assert flatten_list([1, [2, 3], [4, [5]]]) == [1, 2, 3, 4, 5]"}, | |
| {"name": "already flat", "code": "assert flatten_list([1, 2, 3]) == [1, 2, 3]"}, | |
| {"name": "empty", "code": "assert flatten_list([]) == []"}, | |
| {"name": "deep nesting", "code": "assert flatten_list([[[[1]]]]) == [1]"} | |
| ] | |
| }, | |
| { | |
| "function_name": "binary_search", | |
| "buggy_code": "def binary_search(arr, target):\n left, right = 0, len(arr) - 1\n while left < right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid\n else:\n right = mid - 1\n return -1", | |
| "correct_code": "def binary_search(arr, target):\n left, right = 0, len(arr) - 1\n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n return -1", | |
| "bug_description": "Uses < instead of <= in while condition, and left=mid instead of left=mid+1", | |
| "tests": [ | |
| {"name": "found middle", "code": "assert binary_search([1,2,3,4,5], 3) == 2"}, | |
| {"name": "found first", "code": "assert binary_search([1,2,3,4,5], 1) == 0"}, | |
| {"name": "found last", "code": "assert binary_search([1,2,3,4,5], 5) == 4"}, | |
| {"name": "not found", "code": "assert binary_search([1,2,3,4,5], 6) == -1"} | |
| ] | |
| }, | |
| { | |
| "function_name": "merge_sorted", | |
| "buggy_code": "def merge_sorted(a, b):\n result = []\n i = j = 0\n while i < len(a) and j < len(b):\n if a[i] <= b[j]:\n result.append(a[i])\n i += 1\n else:\n result.append(b[j])\n j += 1\n return result", | |
| "correct_code": "def merge_sorted(a, b):\n result = []\n i = j = 0\n while i < len(a) and j < len(b):\n if a[i] <= b[j]:\n result.append(a[i])\n i += 1\n else:\n result.append(b[j])\n j += 1\n result.extend(a[i:])\n result.extend(b[j:])\n return result", | |
| "bug_description": "Missing the remaining elements after the while loop ends", | |
| "tests": [ | |
| {"name": "basic merge", "code": "assert merge_sorted([1,3,5], [2,4,6]) == [1,2,3,4,5,6]"}, | |
| {"name": "one empty", "code": "assert merge_sorted([], [1,2,3]) == [1,2,3]"}, | |
| {"name": "both empty", "code": "assert merge_sorted([], []) == []"}, | |
| {"name": "unequal length", "code": "assert merge_sorted([1], [2,3,4]) == [1,2,3,4]"} | |
| ] | |
| }, | |
| { | |
| "function_name": "remove_duplicates", | |
| "buggy_code": "def remove_duplicates(lst):\n seen = set()\n result = []\n for item in lst:\n if item in seen:\n result.append(item)\n seen.add(item)\n return result", | |
| "correct_code": "def remove_duplicates(lst):\n seen = set()\n result = []\n for item in lst:\n if item not in seen:\n result.append(item)\n seen.add(item)\n return result", | |
| "bug_description": "Condition is inverted: keeps duplicates and removes unique items", | |
| "tests": [ | |
| {"name": "basic dedup", "code": "assert remove_duplicates([1,2,2,3,3,3]) == [1,2,3]"}, | |
| {"name": "no duplicates", "code": "assert remove_duplicates([1,2,3]) == [1,2,3]"}, | |
| {"name": "all same", "code": "assert remove_duplicates([5,5,5]) == [5]"}, | |
| {"name": "empty", "code": "assert remove_duplicates([]) == []"} | |
| ] | |
| } | |
| ] | |