Skip to content

Commit 11f331d

Browse files
authored
Create IncorporatingFailedQuery.txt
1 parent 7ca6ce5 commit 11f331d

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

queries/IncorporatingFailedQuery.txt

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
Write a python program to do the following please, and put this program in a json object as the value
2+
corresponding to the key `code'.
3+
4+
Solve a given equation and return the value of `x' in the form of string "x=#value". The equation contains
5+
only `+', `-' operation, the variable `x' and its coefficient.
6+
7+
If there is no solution for the equation, return "No solution".
8+
9+
If there are infinite solutions for the equation, return "Infinite solutions".
10+
11+
If there is exactly one solution for the equation, we ensure that the value of `x' is an integer.
12+
13+
14+
Example 1:
15+
Input: "x+5-3+x=6+x-2"
16+
Output: "x=2"
17+
18+
Example 2:
19+
Input: "x=x"
20+
Output: "Infinite solutions"
21+
22+
Example 3:
23+
Input: "2x=x"
24+
Output: "x=0"
25+
26+
Example 4:
27+
Input: "2x+3x-6x=x+2"
28+
Output: "x=-1"
29+
30+
Example 5:
31+
Input: "x=x+2"
32+
Output: "No solution"
33+
34+
Here is a test case that the previous program failed because ValueError: invalid literal for int() with
35+
base 10: `+' constant += int(term) Line 58 in get_coefficient_and_constant (Solution.py) left_coefficient,
36+
left_constant = self.get_coefficient_and_constant(left_side) Line 9 in solveEquation (Solution.py)
37+
ret = Solution().solveEquation(param_1) Line 79 in _driver (Solution.py) _driver() Line 90 in <module>
38+
(Solution.py). Please write code with this test case in mind, and error in mind.
39+
40+
Write code that fits the following template. Please put this program in a json object as the value
41+
corresponding to the key `code'.
42+
43+
The program should continue below the following lines:
44+
class Solution:
45+
def solveEquation(self, equation: str) -> str:

0 commit comments

Comments
 (0)