Problem p00301 - Generation 2

Orig Description

Symmetric Ternary
It is known that if there is one weight of 1 gram, 3 grams, 9 grams, and 27 grams, you can use a balance to measure from 1 gram to 40 grams at 1 gram intervals. For example, if you place the weight you want to measure and a 3-gram weight on one side of the balance, and a 27-gram and a 1-gram weight on the other side, you know that the weight of the object you want to measure is 27-3+1=25 grams. Furthermore, if there is one weight of 1 (= 3 0) gram, 3 1 grams, ..., 3 n-1 grams, and 3 n grams, it is known that you can measure up to (3 n +1-1)/2 grams using a balance. It is also known that there is only one way to place weights so that the balance is balanced.
You can represent the way weights are placed on the balance by a string by placing the weight you want to measure and the weight on a balance, and indicating with "-" if it is on the same side as the weight of the 3 i grams, "+" if it is on the other side, and "0" if it is not placed on either side, write it in the i-th position from the right end of the string (counting the right end as 0). For example, the example of 25 grams above can be represented as "+0-+".
Now, given the weight you want to measure, create a program that outputs a string representing how to place the weights so that the balance is balanced. However, it is assumed that there is always one weight of 3 to the power of n grams for any weight.
(Note: About symmetric ternary)
The string representing the way weights are placed is called the symmetric ternary of w, which is a number represented by placing powers of 3 and writing characters representing the numbers 1, 0, and -1 for each digit. In the above string, the characters "+", "0", and "-" correspond to the numbers 1, 0, and -1, respectively. For example, the symmetric ternary of "+0-+" representing the way to weigh 25 grams represents the number 1 × 33 + 0 × 32 - 1 × 31 + 1 × 30 = 25.
Input
The input is given in the following format:
w
w (1 ≤ w ≤ 100000) is an integer representing the weight of the object to be measured.
Output
Output a string representing how to place the weights. However, the left end of the string must not be 0.
Examples
Example 1
Input:
25
Output:
+0-+
Example 2
Input:
2
Output:
+-
Example 3
Input:
5
Output:
+--

Extracted Specification

An integer w (1 ≤ w ≤ 100000), representing some quantity.

### Example Input:

```
25
```

### Function Signature:
Write a function f(w) that takes in the input. 
def f(w: int): 
    ''' 
    w: an integer 
    '''

Test Case Generator

Certainly! Here's a detailed test case generator for the "Symmetric Ternary" problem:

```python
import random

def generate_test_case():
    w = random.randint(1, 100000)
    return w

# Example usage:
if __name__ == "__main__":
    random.seed(42)  # For reproducibility
    for _ in range(5):  # Generate 5 example test cases
        test_case = generate_test_case()
        print(test_case)

```

This function `generate_test_case` generates a random integer `w` within the specified range (1 ≤ w ≤ 100000). You can run this script to generate multiple test cases. 

Here's a breakdown of how it works:
1. **`random.randint(1, 100000)`**: This will generate a random integer within the given range.
2. **Example Usage Section**: This part of the code is to illustrate how you can generate multiple test cases. By running the script, you will get 5 different test cases printed out.

You can modify the number of test cases to generate by changing the range in the `for` loop.

If you need to integrate this into a larger test suite or use it in a competitive programming environment, you can adapt the function accordingly.

Extract Arguments

def extract_arguments(fh):
    w = int(fh.readline().strip())
    return (w,)

# Example usage in the main function
# if __name__ == "__main__":
#     input_path = sys.argv[1]
#     with open(input_path, 'r') as fh:
#         args = extract_arguments(fh)
#         f(*args)