Orig Description
Score : 100 points
Problem StatementThere is always an integer in Takahashi's mind.
Initially, the integer in Takahashi's mind is 0. Takahashi is now going to eat four symbols, each of which is + or -. When he eats +, the integer in his mind increases by 1; when he eats -, the integer in his mind decreases by 1.
The symbols Takahashi is going to eat are given to you as a string S. The i-th character in S is the i-th symbol for him to eat.
Find the integer in Takahashi's mind after he eats all the symbols.
Constraints
The length of S is 4.
Each character in S is + or -.
InputInput is given from Standard Input in the following format:
S
OutputPrint the integer in Takahashi's mind after he eats all the symbols.
Sample Input 1+-++
Sample Output 12
Initially, the integer in Takahashi's mind is 0.
The first integer for him to eat is +. After eating it, the integer in his mind becomes 1.
The second integer to eat is -. After eating it, the integer in his mind becomes 0.
The third integer to eat is +. After eating it, the integer in his mind becomes 1.
The fourth integer to eat is +. After eating it, the integer in his mind becomes 2.
Thus, the integer in Takahashi's mind after he eats all the symbols is 2.
Sample Input 2-+--
Sample Output 2-2
Sample Input 3----
Sample Output 3-4
Extracted Specification
An input string \( S \) of length 4, where each character in \( S \) is either '+' or '-'.
### Example Input:
```
+-++
```
### Function Signature:
Write a function f(S) that takes in the input.
```python
def f(S: str):
'''
S: a string of length 4 containing only '+' and '-'
'''
```
Test Case Generator
Sure, I can help you write a test case generator for the given problem statement. Here's how you can generate test cases for this problem:
```python
import random
def tcgen():
# Length of S is fixed at 4
length_of_S = 4
# Each character in S can be either '+' or '-'
S = ''.join(random.choice(['+', '-']) for _ in range(length_of_S))
return S
# Example of generating a test case
print(tcgen())
```
This function generates a random string `S` of length 4, where each character is either '+' or '-'. This aligns with the constraints provided in the problem statement.
You can run this function multiple times to generate different test cases for the problem. For example:
```python
for _ in range(5): # Generate 5 test cases
print(tcgen())
```
This will output something like:
```
+--+
-++-
++--
--++
-+-+
```
Extract Arguments
def extract_arguments(fh):
S = fh.readline().strip()
return S