Dataset Viewer
Auto-converted to Parquet Duplicate
original_text
stringlengths
2.54k
9.36k
problem
stringlengths
302
1.56k
bug_code
stringlengths
41
5.44k
bug_desc
stringlengths
46
325
bug_fixes
stringlengths
31
471
unit_tests
stringlengths
128
531
id
stringlengths
10
28
original_text_for_feedback
stringlengths
915
3.03k
conversation
stringlengths
2.74k
10.4k
<problem> Create a function `fibonacci(n:int)` that takes in a parameter `n`, an integer representing the number of terms in the Fibonacci sequence to generate, and returns: - 'OOPS', if `n` is less than or equal to 0 - `1` if `n` is equal to `1` - `1` if `n` is equal to `2` - Otherwise, return the nth term of the F...
Create a function `fibonacci(n:int)` that takes in a parameter `n`, an integer representing the number of terms in the Fibonacci sequence to generate, and returns: - 'OOPS', if `n` is less than or equal to 0 - `1` if `n` is equal to `1` - `1` if `n` is equal to `2` - Otherwise, return the nth term of the Fibonacci s...
def fibonacci(n): if n <= 0: return "OOPS" elif n == 1: return 1 elif n == 2: return 1 else: a = 0 b = 1 for i in range(0, n): temp = b b = a + b a = temp return b
On line 11, the for loop iterates `n` times. Consequently, the function returns the (n+1)th term of the Fibonacci sequence instead of the nth term, as the loop generates one additional term beyond the desired nth term.
Replace `range(0, n)` with `range(1, n)` on line 11. Replace `range(0, n)` with `range(0, n - 1)` on line 11. Replace `range(0, n)` with `range(2, n + 1)` on line 11.
assert fibonacci(0) == 'OOPS' assert fibonacci(1) == 1 assert fibonacci(2) == 1 assert fibonacci(5) == 5 assert fibonacci(-3) == 'OOPS' assert fibonacci(10) == 55
0_0_fibonacci
<problem> Create a function `fibonacci(n:int)` that takes in a parameter `n`, an integer representing the number of terms in the Fibonacci sequence to generate, and returns: - 'OOPS', if `n` is less than or equal to 0 - `1` if `n` is equal to `1` - `1` if `n` is equal to `2` - Otherwise, return the nth term of the F...
{'system': '<problem>\nCreate a function `fibonacci(n:int)` that takes in a parameter `n`, an integer representing the number of terms in the Fibonacci sequence to generate, and returns:\n- \'OOPS\', if `n` is less than or equal to 0 \n- `1` if `n` is equal to `1`\n- `1` if `n` is equal to `2`\n- Otherwise, return th...
<problem> Create a function `fibonacci(n:int)` that takes in a parameter `n`, an integer representing the number of terms in the Fibonacci sequence to generate, and returns: - 'OOPS', if `n` is less than or equal to 0 - `1` if `n` is equal to `1` - `1` if `n` is equal to `2` - Otherwise, return the nth term of the F...
Create a function `fibonacci(n:int)` that takes in a parameter `n`, an integer representing the number of terms in the Fibonacci sequence to generate, and returns: - 'OOPS', if `n` is less than or equal to 0 - `1` if `n` is equal to `1` - `1` if `n` is equal to `2` - Otherwise, return the nth term of the Fibonacci s...
def fibonacci(n): if n <= 0: return "OOPS" elif n == 1 or n == 2: return 1 else: return fibonacci(n) + fibonacci(n-1)
`fibonacci(n)` calls `fibonacci(n)` on line 7 with the same argument `n` which leads to infinite recursion and consequently a runtime error is thrown.
Replace `fibonacci(n) + fibonacci(n-1)` with `fibonacci(n-1) + fibonacci(n-2)` on line 7.
assert fibonacci(0) == 'OOPS' assert fibonacci(1) == 1 assert fibonacci(2) == 1 assert fibonacci(5) == 5 assert fibonacci(-3) == 'OOPS' assert fibonacci(10) == 55
0_5_fibonacci
<problem> Create a function `fibonacci(n:int)` that takes in a parameter `n`, an integer representing the number of terms in the Fibonacci sequence to generate, and returns: - 'OOPS', if `n` is less than or equal to 0 - `1` if `n` is equal to `1` - `1` if `n` is equal to `2` - Otherwise, return the nth term of the F...
{'system': '<problem>\nCreate a function `fibonacci(n:int)` that takes in a parameter `n`, an integer representing the number of terms in the Fibonacci sequence to generate, and returns:\n- \'OOPS\', if `n` is less than or equal to 0 \n- `1` if `n` is equal to `1`\n- `1` if `n` is equal to `2`\n- Otherwise, return th...
<problem> Create a function `fibonacci(n:int)` that takes in a parameter `n`, an integer representing the number of terms in the Fibonacci sequence to generate, and returns: - 'OOPS', if `n` is less than or equal to 0 - `1` if `n` is equal to `1` - `1` if `n` is equal to `2` - Otherwise, return the nth term of the F...
Create a function `fibonacci(n:int)` that takes in a parameter `n`, an integer representing the number of terms in the Fibonacci sequence to generate, and returns: - 'OOPS', if `n` is less than or equal to 0 - `1` if `n` is equal to `1` - `1` if `n` is equal to `2` - Otherwise, return the nth term of the Fibonacci s...
def fibonacci(n): if n < 0: return "OOPS" elif n == 1: return 1 elif n == 2: return 1 else: a = 0 b = 1 for i in range(1, n): temp = b b = a + b a = temp return b
On line 2, the function only checks if `n` is less than `0` and then returns `OOPS`. When `n` is 0 the function returns `1` which is incorrect. The function should instead return `'OOPS'` when `n` is equal to `0`.
Replace `if n < 0` with `if n <= 0` on line 2.
assert fibonacci(0) == 'OOPS' assert fibonacci(1) == 1 assert fibonacci(2) == 1 assert fibonacci(5) == 5 assert fibonacci(-3) == 'OOPS' assert fibonacci(10) == 55
0_2_fibonacci
<problem> Create a function `fibonacci(n:int)` that takes in a parameter `n`, an integer representing the number of terms in the Fibonacci sequence to generate, and returns: - 'OOPS', if `n` is less than or equal to 0 - `1` if `n` is equal to `1` - `1` if `n` is equal to `2` - Otherwise, return the nth term of the F...
{'system': '<problem>\nCreate a function `fibonacci(n:int)` that takes in a parameter `n`, an integer representing the number of terms in the Fibonacci sequence to generate, and returns:\n- \'OOPS\', if `n` is less than or equal to 0 \n- `1` if `n` is equal to `1`\n- `1` if `n` is equal to `2`\n- Otherwise, return th...
<problem> Create a method `calculateGrade(hw:float, exams: float, projects: float, att:float) -> Tuple[str, int]` that takes in four float parameters between 0 and 100 representing a student's grades in four different categories: Homework (`hw`) which is worth 20% of the final grade, Exams (`exams`) worth 40% of the fi...
Create a method `calculateGrade(hw:float, exams: float, projects: float, att:float) -> Tuple[str, int]` that takes in four float parameters between 0 and 100 representing a student's grades in four different categories: Homework (`hw`) which is worth 20% of the final grade, Exams (`exams`) worth 40% of the final grade,...
def calculateGrade(hw, exams, projects, att): hw = hw * 0.2 exams = exams * 0.4 projects = projects * 0.30 att = att * 0.10 finalScore = hw + exams + projects + att roundedScore = round(finalScore) if finalScore >= 90: letterGrade = "A" elif finalScore >= 80: letterGrade = "B" ...
On lines 10, 12, 14, and 16 the function uses `finalScore`, which is not rounded to the nearest integer, to determine the `letterGrade`. Consequently, the function returns the incorrect `letterGrade` on edge cases where the closest integer is in a new category.
Replace `finalScore` with `roundedScore` on lines 10, 12, 14, and 16.
assert calculateGrade(100, 100, 100, 100) == ('A', 100) assert calculateGrade(100, 89, 85, 90) == ('A', 90) assert calculateGrade(72, 96, 74, 98) == ('B', 85) assert calculateGrade(100, 82, 68, 94) == ('B', 83) assert calculateGrade(75, 60, 73, 100) == ('C', 71) assert calculateGrade(75, 60, 73, 87) == ('C', 70) assert...
1_10_calculating_a_grade
<problem> Create a method `calculateGrade(hw:float, exams: float, projects: float, att:float) -> Tuple[str, int]` that takes in four float parameters between 0 and 100 representing a student's grades in four different categories: Homework (`hw`) which is worth 20% of the final grade, Exams (`exams`) worth 40% of the fi...
{'system': '<problem>\nCreate a method `calculateGrade(hw:float, exams: float, projects: float, att:float) -> Tuple[str, int]` that takes in four float parameters between 0 and 100 representing a student\'s grades in four different categories: Homework (`hw`) which is worth 20% of the final grade, Exams (`exams`) worth...
<problem> Create a method `calculateGrade(hw:float, exams: float, projects: float, att:float) -> Tuple[str, int]` that takes in four float parameters between 0 and 100 representing a student's grades in four different categories: Homework (`hw`) which is worth 20% of the final grade, Exams (`exams`) worth 40% of the fi...
Create a method `calculateGrade(hw:float, exams: float, projects: float, att:float) -> Tuple[str, int]` that takes in four float parameters between 0 and 100 representing a student's grades in four different categories: Homework (`hw`) which is worth 20% of the final grade, Exams (`exams`) worth 40% of the final grade,...
Create a method `calculateGrade(hw:float, exams: float, projects: float, att:float) -> Tuple[str, int]` that takes in four float parameters between 0 and 100 representing a student's grades in four different categories: Homework (`hw`) which is worth 20% of the final grade, Exams (`exams`) worth 40% of the final grade,...
The return statement on line 15 is never executed. Consequently, the function only returns a string `letterGrade` instead of returning a tuple with a string and an integer containing the letter grade and the rounded final score respectively.
Remove line 15 and replace `letterGrade` with `(letterGrade, roundedScore)` on line 15.
assert calculateGrade(100, 100, 100, 100) == ('A', 100) assert calculateGrade(100, 89, 85, 90) == ('A', 90) assert calculateGrade(72, 96, 74, 98) == ('B', 85) assert calculateGrade(100, 82, 68, 94) == ('B', 83) assert calculateGrade(75, 60, 73, 100) == ('C', 71) assert calculateGrade(75, 60, 73, 87) == ('C', 70) assert...
1_11_calculating_a_grade
<problem> Create a method `calculateGrade(hw:float, exams: float, projects: float, att:float) -> Tuple[str, int]` that takes in four float parameters between 0 and 100 representing a student's grades in four different categories: Homework (`hw`) which is worth 20% of the final grade, Exams (`exams`) worth 40% of the fi...
{'system': "<problem>\nCreate a method `calculateGrade(hw:float, exams: float, projects: float, att:float) -> Tuple[str, int]` that takes in four float parameters between 0 and 100 representing a student's grades in four different categories: Homework (`hw`) which is worth 20% of the final grade, Exams (`exams`) worth ...
<problem> Create a method `calculateGrade(hw:float, exams: float, projects: float, att:float) -> Tuple[str, int]` that takes in four float parameters between 0 and 100 representing a student's grades in four different categories: Homework (`hw`) which is worth 20% of the final grade, Exams (`exams`) worth 40% of the fi...
Create a method `calculateGrade(hw:float, exams: float, projects: float, att:float) -> Tuple[str, int]` that takes in four float parameters between 0 and 100 representing a student's grades in four different categories: Homework (`hw`) which is worth 20% of the final grade, Exams (`exams`) worth 40% of the final grade,...
def calculateGrade(hw, exams, projects, att): weights = [0.1, 0.3, 0.4, 0.2] grades = [hw, exams, projects, att] final_grade = 0 for i in range(len(weights)): final_grade += weights[i] * grades[i] final_grade = round(final_grade) if final_grade >= 90: return ('A', final_grade) eli...
On lines 2 and 3, the `weights` and `grades` are not parallel arrays. Consequently, the function will return an incorrect weighted sum of the final grade.
On line 2 replace `[0.1, 0.3, 0.4, 0.2]` with `[0.2, 0.4, 0.3, 0.1]`. On line 3 replace `[hw, exams, projects, att]` with ` [att, projects, exams, hw]`.
assert calculateGrade(100, 100, 100, 100) == ('A', 100) assert calculateGrade(100, 89, 85, 90) == ('A', 90) assert calculateGrade(75, 60, 73, 100) == ('C', 71) assert calculateGrade(75, 60, 73, 87) == ('C', 70) assert calculateGrade(70, 60, 65, 70) == ('D', 64) assert calculateGrade(0, 0, 0, 0) == ('F', 0)
1_13_calculating_a_grade
<problem> Create a method `calculateGrade(hw:float, exams: float, projects: float, att:float) -> Tuple[str, int]` that takes in four float parameters between 0 and 100 representing a student's grades in four different categories: Homework (`hw`) which is worth 20% of the final grade, Exams (`exams`) worth 40% of the fi...
{'system': "<problem>\nCreate a method `calculateGrade(hw:float, exams: float, projects: float, att:float) -> Tuple[str, int]` that takes in four float parameters between 0 and 100 representing a student's grades in four different categories: Homework (`hw`) which is worth 20% of the final grade, Exams (`exams`) worth ...
<problem> Create a method `calculateGrade(hw:float, exams: float, projects: float, att:float) -> Tuple[str, int]` that takes in four float parameters between 0 and 100 representing a student's grades in four different categories: Homework (`hw`) which is worth 20% of the final grade, Exams (`exams`) worth 40% of the fi...
Create a method `calculateGrade(hw:float, exams: float, projects: float, att:float) -> Tuple[str, int]` that takes in four float parameters between 0 and 100 representing a student's grades in four different categories: Homework (`hw`) which is worth 20% of the final grade, Exams (`exams`) worth 40% of the final grade,...
def calculateGrade(hw, exams, projects, att): finalScore = hw * 0.2 + exams * 0.4 + projects * 0.3 + att * 0.1 roundedScore = round(finalScore) if roundedScore > 90: letterGrade = "A" elif roundedScore >= 80: letterGrade = "B" elif roundedScore >= 70: letterGrade = "C" elif rounde...
When `roundedScore` is `90` the if statement on line 4 evaluates to False, since `90` is not strictly greater than `90`. Consequently, the function assigns `B` to `letterGrade` which is incorrect.
Replace `roundedScore > 90` with `roundedScore >= 90` on line 4.
assert calculateGrade(100, 100, 100, 100) == ('A', 100) assert calculateGrade(100, 89, 85, 90) == ('A', 90) assert calculateGrade(72, 96, 74, 98) == ('B', 85) assert calculateGrade(100, 82, 68, 94) == ('B', 83) assert calculateGrade(75, 60, 73, 100) == ('C', 71) assert calculateGrade(75, 60, 73, 87) == ('C', 70) assert...
1_8_calculating_a_grade
<problem> Create a method `calculateGrade(hw:float, exams: float, projects: float, att:float) -> Tuple[str, int]` that takes in four float parameters between 0 and 100 representing a student's grades in four different categories: Homework (`hw`) which is worth 20% of the final grade, Exams (`exams`) worth 40% of the fi...
{'system': '<problem>\nCreate a method `calculateGrade(hw:float, exams: float, projects: float, att:float) -> Tuple[str, int]` that takes in four float parameters between 0 and 100 representing a student\'s grades in four different categories: Homework (`hw`) which is worth 20% of the final grade, Exams (`exams`) worth...
<problem> Create a method `toxNGLXSH(sen:str) -> str` that converts an English sentence to xNGLXSH in which every lowercase vowel is replaced with 'X', each uppercase vowel is replaced with 'x', every lowercase consonant is replaced with its uppercase version, and every uppercase consonant is replaced with its lowercas...
Create a method `toxNGLXSH(sen:str) -> str` that converts an English sentence to xNGLXSH in which every lowercase vowel is replaced with 'X', each uppercase vowel is replaced with 'x', every lowercase consonant is replaced with its uppercase version, and every uppercase consonant is replaced with its lowercase version....
def toxNGLXSH(sen): vowels = ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"] for i in vowels: if i.islower(): sen.replace(i, "x") else: sen.replace(i, "X") sen.swapcase() return sen
On lines 5, 7, and 8, the calls `sen.replace` and `sen.swapcase` leave `sen` unchanged, because strings are immutable in Python. Consequently, the function returns `sen` as it is.
Replace `sen.swapcase()` with `sen = sen.swapcase()` on line 8 and on lines 5 and 7 change `sen.replace` to `sen = sen.replace`.
assert toxNGLXSH('English') == 'xNGLXSH' assert toxNGLXSH('hello there!') == 'HXLLX THXRX!' assert toxNGLXSH("My name is John!") == 'mY NXMX XS jXHN!' assert toxNGLXSH('To be or not to be!') == 'tX BX XR NXT TX BX!' assert toxNGLXSH('The quick brown fox jumped over the lazy rabbit.') == 'tHX QXXCK BRXWN FXX JXMPXD XVXR...
10_39_xnglxsh
<problem> Create a method `toxNGLXSH(sen:str) -> str` that converts an English sentence to xNGLXSH in which every lowercase vowel is replaced with 'X', each uppercase vowel is replaced with 'x', every lowercase consonant is replaced with its uppercase version, and every uppercase consonant is replaced with its lowercas...
{'system': '<problem>\nCreate a method `toxNGLXSH(sen:str) -> str` that converts an English sentence to xNGLXSH in which every lowercase vowel is replaced with \'X\', each uppercase vowel is replaced with \'x\', every lowercase consonant is replaced with its uppercase version, and every uppercase consonant is replaced ...
<problem> Write a function called `is_palindrome(string:str) -> bool` that returns True if the string is a palindrome and False otherwise. A palindrome is a string that is the same when read forwards and backwards. ## Example Cases: ``` is_palindrome("racecar") => True is_palindrome("hello") => False is_palindrome("han...
Write a function called `is_palindrome(string:str) -> bool` that returns True if the string is a palindrome and False otherwise. A palindrome is a string that is the same when read forwards and backwards. ## Example Cases: ``` is_palindrome("racecar") => True is_palindrome("hello") => False is_palindrome("hannah") => T...
def is_palindrome(string): rev_string = '' for i in string: rev_string = i + rev_string if rev_string = string: return True else: return False
On line 5, the function throws a syntax error.
Replace `=` with `==` on line 5.
assert is_palindrome("racecar") == True assert is_palindrome("hello") == False assert is_palindrome("hannah") == True assert is_palindrome("firetruck") == False assert is_palindrome("nice") == False assert is_palindrome("") == True
11_40_palindrome
<problem> Write a function called `is_palindrome(string:str) -> bool` that returns True if the string is a palindrome and False otherwise. A palindrome is a string that is the same when read forwards and backwards. ## Example Cases: ``` is_palindrome("racecar") => True is_palindrome("hello") => False is_palindrome("han...
{'system': '<problem>\nWrite a function called `is_palindrome(string:str) -> bool` that returns True if the string is a palindrome and False otherwise. A palindrome is a string that is the same when read forwards and backwards.\n## Example Cases:\n```\nis_palindrome("racecar") => True\nis_palindrome("hello") => False\n...
<problem> Write a function `reverse_list(lst:List[any]) -> List[any]` that returns `lst` in reverse order. ## Example Cases: ``` reverse_list([1, 2, 3]) => [3, 2, 1] reverse_list([1, 2, 3, 4, 5]) => [5, 4, 3, 2, 1] reverse_list([]) => [] reverse_list(["Hi", "Hello", "Goodbye"]) => ["Goodbye", "Hello", "Hi"] ``` </probl...
Write a function `reverse_list(lst:List[any]) -> List[any]` that returns `lst` in reverse order. ## Example Cases: ``` reverse_list([1, 2, 3]) => [3, 2, 1] reverse_list([1, 2, 3, 4, 5]) => [5, 4, 3, 2, 1] reverse_list([]) => [] reverse_list(["Hi", "Hello", "Goodbye"]) => ["Goodbye", "Hello", "Hi"] ```
def reverse_list(lst): return lst[-1:]
On line 2, the way the slice operator is used creates a list containing only the last element in `lst` instead of a list containing all the elements of `lst` in reverse order.
Replace `return lst[-1:]` with `return lst[::-1]` on line 2.
assert reverse_list([1, 2, 3]) == [3, 2, 1] assert reverse_list([1, 2, 3, 4, 5]) == [5, 4, 3, 2, 1] assert reverse_list([]) == [] assert reverse_list(["Hi", "Hello", "Goodbye"]) == ["Goodbye", "Hello", "Hi"]
12_41_reversing_a_list
<problem> Write a function `reverse_list(lst:List[any]) -> List[any]` that returns `lst` in reverse order. ## Example Cases: ``` reverse_list([1, 2, 3]) => [3, 2, 1] reverse_list([1, 2, 3, 4, 5]) => [5, 4, 3, 2, 1] reverse_list([]) => [] reverse_list(["Hi", "Hello", "Goodbye"]) => ["Goodbye", "Hello", "Hi"] ``` </probl...
{'system': '<problem>\nWrite a function `reverse_list(lst:List[any]) -> List[any]` that returns `lst` in reverse order.\n## Example Cases:\n```\nreverse_list([1, 2, 3]) => [3, 2, 1]\nreverse_list([1, 2, 3, 4, 5]) => [5, 4, 3, 2, 1]\nreverse_list([]) => []\nreverse_list(["Hi", "Hello", "Goodbye"]) => ["Goodbye", "Hello"...
<problem> Write a function `isTwice(string:str, char:str) -> bool` that returns `True` if the character `char` appears exactly twice in the string `string`. Otherwise, it returns `False`. ## Example Cases: ``` isTwice("hello", "l") => True isTwice("hello", "o") => False isTwice("hello", "h") => False isTwice("", "e") =...
Write a function `isTwice(string:str, char:str) -> bool` that returns `True` if the character `char` appears exactly twice in the string `string`. Otherwise, it returns `False`. ## Example Cases: ``` isTwice("hello", "l") => True isTwice("hello", "o") => False isTwice("hello", "h") => False isTwice("", "e") => False is...
def isTwice(str, chr): count = 0 for i in str: if i == chr: count+=1 if count >= 2: return true else: return false
On line 8, the function throws a NameError since `true` is not a boolean value.
Replace `true` with `True` and `false` with `False` on lines 8 and 10.
assert isTwice("hello", "l") == True assert isTwice("hello", "o") == False assert isTwice("hello", "h") == False assert isTwice("", "e") == False assert isTwice("I'm a string!", " ") == True assert isTwice("Hey, I'm a string!", " ") == False
14_43_used_twice
<problem> Write a function `isTwice(string:str, char:str) -> bool` that returns `True` if the character `char` appears exactly twice in the string `string`. Otherwise, it returns `False`. ## Example Cases: ``` isTwice("hello", "l") => True isTwice("hello", "o") => False isTwice("hello", "h") => False isTwice("", "e") =...
{'system': '<problem>\nWrite a function `isTwice(string:str, char:str) -> bool` that returns `True` if the character `char` appears exactly twice in the string `string`. Otherwise, it returns `False`.\n## Example Cases:\n```\nisTwice("hello", "l") => True\nisTwice("hello", "o") => False\nisTwice("hello", "h") => False\...
<problem> Write a function `search(x: int, seq: List[int]) -> int` that returns the index of the first occurrence of `x` in `seq`. If `x` is not in `seq`, return the index where `x` should be inserted to keep `seq` sorted. Assume that `seq` is sorted in ascending order. ## Example Cases: ``` search(5, [-1, 5, 8, 10, 12...
Write a function `search(x: int, seq: List[int]) -> int` that returns the index of the first occurrence of `x` in `seq`. If `x` is not in `seq`, return the index where `x` should be inserted to keep `seq` sorted. Assume that `seq` is sorted in ascending order. ## Example Cases: ``` search(5, [-1, 5, 8, 10, 12]) => 1 se...
def search(x, seq): for i in range(len(seq)): if x <= seq[i]: return i
The function returns `None` when `x` is greater than all of the elements in `seq` instead of returning the index indicating that `x` should be inserted at the end of the array.
Insert a line following line 4, with one indentation containing `return len(seq)`
assert search(5, [-1, 5, 8, 10, 12]) == 1 assert search(-2, [-1, 57, 65]) == 0 assert search(0, [-120, 60, 78, 100]) == 1 assert search(77, [-100, -50, 5, 44, 66, 76, 99] ) == 6 assert search(55, [-99, -2, 0]) == 3
15_45_sequential_search
<problem> Write a function `search(x: int, seq: List[int]) -> int` that returns the index of the first occurrence of `x` in `seq`. If `x` is not in `seq`, return the index where `x` should be inserted to keep `seq` sorted. Assume that `seq` is sorted in ascending order. ## Example Cases: ``` search(5, [-1, 5, 8, 10, 12...
{'system': '<problem>\nWrite a function `search(x: int, seq: List[int]) -> int` that returns the index of the first occurrence of `x` in `seq`. If `x` is not in `seq`, return the index where `x` should be inserted to keep `seq` sorted. Assume that `seq` is sorted in ascending order.\n## Example Cases:\n```\nsearch(5, [...
<problem> Write a function `search(x: int, seq: List[int]) -> int` that returns the index of the first occurrence of `x` in `seq`. If `x` is not in `seq`, return the index where `x` should be inserted to keep `seq` sorted. Assume that `seq` is sorted in ascending order. ## Example Cases: ``` search(5, [-1, 5, 8, 10, 12...
Write a function `search(x: int, seq: List[int]) -> int` that returns the index of the first occurrence of `x` in `seq`. If `x` is not in `seq`, return the index where `x` should be inserted to keep `seq` sorted. Assume that `seq` is sorted in ascending order. ## Example Cases: ``` search(5, [-1, 5, 8, 10, 12]) => 1 se...
def search(x, seq): for i in range(len(seq)): if x < seq[i]: return i return len(seq)
On line 3, the function only checks if `x` is less than `seq[i]` and then returns the index `i` where `x` should be inserted. When `x` is in `seq` at position `i`, the function returns the next index `i + 1` instead of the current index `i`.
Replace `<` with `<=` on line 3
assert search(5, [-1, 5, 8, 10, 12]) == 1 assert search(-2, [-1, 57, 65]) == 0 assert search(0, [-120, 60, 78, 100]) == 1 assert search(77, [-100, -50, 5, 44, 66, 76, 99] ) == 6 assert search(55, [-99, -2, 0]) == 3
15_44_sequential_search
<problem> Write a function `search(x: int, seq: List[int]) -> int` that returns the index of the first occurrence of `x` in `seq`. If `x` is not in `seq`, return the index where `x` should be inserted to keep `seq` sorted. Assume that `seq` is sorted in ascending order. ## Example Cases: ``` search(5, [-1, 5, 8, 10, 12...
{'system': '<problem>\nWrite a function `search(x: int, seq: List[int]) -> int` that returns the index of the first occurrence of `x` in `seq`. If `x` is not in `seq`, return the index where `x` should be inserted to keep `seq` sorted. Assume that `seq` is sorted in ascending order.\n## Example Cases:\n```\nsearch(5, [...
<problem> Write a function `substr_len(s: str, t: str) -> int` that takes as input a string `s` and a non-empty string `t` and returns the length of the longest substring of `s` that does not contain `t`. For example, if `s = "abracadabra"` and `t = "ca"`, then the longest substring of `s` that does not contain `t` is ...
Write a function `substr_len(s: str, t: str) -> int` that takes as input a string `s` and a non-empty string `t` and returns the length of the longest substring of `s` that does not contain `t`. For example, if `s = "abracadabra"` and `t = "ca"`, then the longest substring of `s` that does not contain `t` is `"dabra"`,...
def substr_len(s, t): max_len = 0 start = 0 pos = s.find(t, start) while pos != -1: crt_str = s[start:pos] max_len = max(len(crt_str), max_len) pos = s.find(t, start) last_str = s[start:] max_len = max(len(last_str), max_len) return max_len
The value of `start` never changes inside the while loop, thus `pos` which is computed based on `start` never changes either. Consequently, the while loop on line 5 never stops.
On line 8 insert the code `start = pos + len(t)`.
assert substr_len("abracadabra", "ca") == 5 assert substr_len("I love Python", "Py") == 7 assert substr_len("contest", "test") == 3 assert substr_len("icey ice", "ice") == 2 assert substr_len("icey ice cream", "ice") == 6 assert substr_len("abracadabra", "abba") == 11
16_56_substring_length
<problem> Write a function `substr_len(s: str, t: str) -> int` that takes as input a string `s` and a non-empty string `t` and returns the length of the longest substring of `s` that does not contain `t`. For example, if `s = "abracadabra"` and `t = "ca"`, then the longest substring of `s` that does not contain `t` is ...
{'system': '<problem>\nWrite a function `substr_len(s: str, t: str) -> int` that takes as input a string `s` and a non-empty string `t` and returns the length of the longest substring of `s` that does not contain `t`. For example, if `s = "abracadabra"` and `t = "ca"`, then the longest substring of `s` that does not co...
End of preview. Expand in Data Studio

Socratic benchmark

Dataset Description

The Socratic benchmark is a dataset of tutor-student interactions released by Erfan Al-Hossami et al. (see citations bellow). The dataset released here on HuggingFace for easier training and evaluation of feedback/tutor language models.

Dataset structure

The dataset structure matches the repository structure as released in the GitHub repo. Each subset corresponds to a version, and each split a subrepo in the corresponding version folder.

Languages

The assignments were written in Python.

Citation Information

All credits should be attributed to the original authors:

@inproceedings{al-hossami-etal-2023-socratic,
    title = "Socratic Questioning of Novice Debuggers: A Benchmark Dataset and Preliminary Evaluations",
    author = "Al-Hossami, Erfan  and
      Bunescu, Razvan  and
      Teehan, Ryan  and
      Powell, Laurel  and
      Mahajan, Khyati  and
      Dorodchi, Mohsen",
    booktitle = "Proceedings of the 18th Workshop on Innovative Use of NLP for Building Educational Applications (BEA 2023)",
    month = jul,
    year = "2023",
    address = "Toronto, Canada",
    publisher = "Association for Computational Linguistics",
    url = "https://aclanthology.org/2023.bea-1.57",
    pages = "709--726",
    abstract = "Socratic questioning is a teaching strategy where the student is guided towards solving a problem on their own, instead of being given the solution directly. In this paper, we introduce a dataset of Socratic conversations where an instructor helps a novice programmer fix buggy solutions to simple computational problems. The dataset is then used for benchmarking the Socratic debugging abilities of GPT-based language models. While GPT-4 is observed to perform much better than GPT-3.5, its precision, and recall still fall short of human expert abilities, motivating further work in this area.",
}
@inproceedings{al-hossami-etal-2024-can,
author = {Al-Hossami, Erfan and Bunescu, Razvan and Smith, Justin and Teehan, Ryan},
title = {Can Language Models Employ the Socratic Method? Experiments with Code Debugging},
year = {2024},
isbn = {9798400704239},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
url = {https://doi.org/10.1145/3626252.3630799},
doi = {10.1145/3626252.3630799},
abstract = {When employing the Socratic method of teaching, instructors guide students toward solving a problem on their own rather than providing the solution directly. While this strategy can substantially improve learning outcomes, it is usually time-consuming and cognitively demanding. Automated Socratic conversational agents can augment human instruction and provide the necessary scale, however their development is hampered by the lack of suitable data for training and evaluation. In this paper, we introduce a manually created dataset of multi-turn Socratic advice that is aimed at helping a novice programmer fix buggy solutions to simple computational problems. The dataset is then used for benchmarking the Socratic debugging abilities of a number of language models, ranging from fine-tuning the instruction-based text-to-text transformer Flan-T5 to zero-shot and chain of thought prompting of the much larger GPT-4. The code and datasets are made freely available for research at the link below.},
booktitle = {Proceedings of the 55th ACM Technical Symposium on Computer Science Education V. 1},
pages = {53–59},
numpages = {7},
keywords = {benchmark dataset, debugging, language models, socratic dialogue},
location = {<conf-loc>, <city>Portland</city>, <state>OR</state>, <country>USA</country>, </conf-loc>},
series = {SIGCSE 2024}
}



### Contributions

[More Information Needed]
Downloads last month
8