#C68. Object Transformation Challenge
Object Transformation Challenge
Object Transformation Challenge
You are given an object with a single property value
. Your task is to apply a series of transformation operations to this object. The available operations are:
increment
: Increasevalue
by 1.double
: Multiplyvalue
by 2.decrement
: Decreasevalue
by 1.
The operations are provided in order, and you must apply them sequentially. For instance, starting with an object { value: 2 }
and applying the operations increment
, double
, and decrement
will produce the object { value: 5 }
because:
\(2 + 1 = 3\), then \(3 \times 2 = 6\), and finally \(6 - 1 = 5\).
Read the description carefully and solve the problem using the appropriate input and output methods as described below.
inputFormat
The input is given via stdin and consists of multiple lines:
- The first line contains an integer (A), representing the initial value of the object.
- The second line contains an integer (N), the number of operations to perform.
- The next (N) lines each contain a string that is either "increment", "double", or "decrement", representing the operation to apply.
outputFormat
Output a single integer to stdout representing the final value of the object after performing all the operations.## sample
2
3
increment
double
decrement
5
</p>