Problem Statement
Please write a function called "adder" that can accept an arbitrary number of arguments.
The adder function should add the first argument, then subtract the second argument, add the third argument, and so on.
Please only submit the adder function that you define.
You may test your adder function locally by inserting the following snippet in your code:
if __name__ == '__main__':
t = int(input())
for i in range(1, t+1):
args = map(int, input().split())
print("Case #%d: %d" % (i, adder(*args)))
Input Specification
The first line of the input gives the number of test cases, , test cases follow. Each test case consists of a line. The line contains arguments of adder function, seperated by a space.
Limits
Memory limits: 32MB.
Time limits: 1 second.
Test Set 1
Sample Case
Test Set 2
Test Set 3
Test Set 4
Output Specification
For each test case, output one line containing Case #x: y
, where is the case number(starting from 1), and is the result after calling your adder function.
Sample Input
3
3 0 1
1
-7 4 8 -5
Sample Output
Case #1: 4
Case #2: 1
Case #3: 2
Explaination
In Case#1 we will call adder(3,0,1) in our main function, the result will be since
In Case#2 we will call adder(1) in our main function, the result will be .
In Case#3 we will call adder(-7,4,8,-5) in our main function, the result will be since
Hint
Variable Length Arguments
Comments