I am referring to this problem in this question: https://www.vivasoftltd.com/getting-testcase-based-i-o-without-any-loop-in-golang/
PROBLEM STATEMENT – We want you to calculate the sum of squares of given integers, excluding any negatives. – The first line of the input will be an integer N (1 <= N <= 100), indicating the number of test cases to follow. – Each of the test cases will consist of a line with an integer X (0 < X <= 100), followed by another line consisting of X number of space-separated integers Yn(-100 <= Yn<= 100). – For each test case, calculate the sum of squares of the integers, excluding any negatives, and print the calculated sum in the output.
Note 1: Do not put blank lines between test case solutions. Note 2: Take input from standard input and output to standard output.
RULES – Do not use any Loop statement – You may only use standard library packages – There should be no output until all the input has been received.
3 -1 1 14
9 6 -53 32 16
The question gets rid of the “no for loop” rule by using recursion. But responses on this thread lead be to believe that this question is not intended to be done with recursion:
They suggest using channels and goroutines to solve this question. I am having a hard time understanding how that would work.