Back
Close

Solve the equation

Statement

 Goal

You must output the value of x.
Input
Line 1: An equation taking the form of ax+b+c+...=A
The term with x is always the first one on the left.
Right side is always only one integer.
Output
Line 1: The value of x.
Constraints
The term containing x is always first in the left side of the equation.
The term containing x can have a coefficient.
Either subtraction or addition is used in the equation.
Only integers are used in the equation, however the answer can be a float.
Example
Input
x+2=4
Output
2

Game modes
Fastest, Shortest, Reverse

Test cases
Test 1 Test
Input
x+2=4
Output
2

Validator 1 Validator
Input
x+2=6
Output
4

Test 2 Test
Input
x-2=4
Output
6

Validator 2 Validator
Input
x-6=10
Output
16

Test 3 Test
Input
4x-2=-4
Output
-0.5

Validator 3 Validator
Input
4x-2=-8
Output
-1.5

Test 4 Test
Input
2x+1-5=7
Output
5.5

Validator 4 Validator
Input
2x+5-2=10
Output
3.5

Test 5 Test
Input
5x-4+5=10
Output
1.8

Validator 5 Validator
Input
5x-2+1=12
Output
2.6

Solution language

Solution

Stub generator input