Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -23,37 +23,29 @@ and then generate the corresponding fixed code. The two tasks are detailed as fo
|
|
| 23 |
1. **Generate a comprehensive set of test cases to expose the bug**:
|
| 24 |
- Each test case should include an input and the expected output.
|
| 25 |
- Output the test cases as a JSON list, where each entry is a dictionary with keys "test_input" and "test_output".
|
| 26 |
-
- Write in
|
| 27 |
-
|
| 28 |
-
json
|
| 29 |
-
|
| 30 |
-
block.
|
| 31 |
|
| 32 |
2. **Provide a fixed version**:
|
| 33 |
- Write a correct Python program to fix the bug.
|
| 34 |
-
- Write in
|
| 35 |
-
|
| 36 |
-
python
|
| 37 |
-
|
| 38 |
-
block.
|
| 39 |
- The code should read from standard input and write to standard output, matching the input/output format specified in the problem.
|
| 40 |
|
| 41 |
Here is an example.
|
| 42 |
The faulty Python program is:
|
| 43 |
|
| 44 |
-
python
|
| 45 |
\"\"\"Please write a Python program to sum two integer inputs\"\"\"
|
| 46 |
def add (x, y):
|
| 47 |
return x - y
|
| 48 |
x = int(input())
|
| 49 |
y = int(input())
|
| 50 |
print(add(x,y))
|
| 51 |
-
|
| 52 |
|
| 53 |
|
| 54 |
Testcases that can expose the bug:
|
| 55 |
|
| 56 |
-
json
|
| 57 |
[
|
| 58 |
{{
|
| 59 |
\"test_input\":\"1\n2\",
|
|
@@ -68,18 +60,18 @@ json
|
|
| 68 |
\"test_output\":\"1\"
|
| 69 |
}}
|
| 70 |
]
|
| 71 |
-
|
| 72 |
|
| 73 |
|
| 74 |
Fixed code:
|
| 75 |
|
| 76 |
-
python
|
| 77 |
def add (x, y):
|
| 78 |
return x + y
|
| 79 |
x = int(input())
|
| 80 |
y = int(input())
|
| 81 |
print(add(x,y))
|
| 82 |
-
|
| 83 |
|
| 84 |
|
| 85 |
Now, you are given a faulty Python function, please return:
|
|
@@ -88,10 +80,9 @@ Now, you are given a faulty Python function, please return:
|
|
| 88 |
|
| 89 |
The faulty function is:
|
| 90 |
|
| 91 |
-
python
|
| 92 |
{faulty_code}
|
| 93 |
-
|
| 94 |
-
|
| 95 |
<|assistant|>
|
| 96 |
"""
|
| 97 |
messages = [
|
|
|
|
| 23 |
1. **Generate a comprehensive set of test cases to expose the bug**:
|
| 24 |
- Each test case should include an input and the expected output.
|
| 25 |
- Output the test cases as a JSON list, where each entry is a dictionary with keys "test_input" and "test_output".
|
| 26 |
+
- Write in ```json ``` block.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
2. **Provide a fixed version**:
|
| 29 |
- Write a correct Python program to fix the bug.
|
| 30 |
+
- Write in ```python ``` block.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
- The code should read from standard input and write to standard output, matching the input/output format specified in the problem.
|
| 32 |
|
| 33 |
Here is an example.
|
| 34 |
The faulty Python program is:
|
| 35 |
|
| 36 |
+
```python
|
| 37 |
\"\"\"Please write a Python program to sum two integer inputs\"\"\"
|
| 38 |
def add (x, y):
|
| 39 |
return x - y
|
| 40 |
x = int(input())
|
| 41 |
y = int(input())
|
| 42 |
print(add(x,y))
|
| 43 |
+
```
|
| 44 |
|
| 45 |
|
| 46 |
Testcases that can expose the bug:
|
| 47 |
|
| 48 |
+
```json
|
| 49 |
[
|
| 50 |
{{
|
| 51 |
\"test_input\":\"1\n2\",
|
|
|
|
| 60 |
\"test_output\":\"1\"
|
| 61 |
}}
|
| 62 |
]
|
| 63 |
+
```
|
| 64 |
|
| 65 |
|
| 66 |
Fixed code:
|
| 67 |
|
| 68 |
+
```python
|
| 69 |
def add (x, y):
|
| 70 |
return x + y
|
| 71 |
x = int(input())
|
| 72 |
y = int(input())
|
| 73 |
print(add(x,y))
|
| 74 |
+
```
|
| 75 |
|
| 76 |
|
| 77 |
Now, you are given a faulty Python function, please return:
|
|
|
|
| 80 |
|
| 81 |
The faulty function is:
|
| 82 |
|
| 83 |
+
```python
|
| 84 |
{faulty_code}
|
| 85 |
+
```
|
|
|
|
| 86 |
<|assistant|>
|
| 87 |
"""
|
| 88 |
messages = [
|