Sum that line X93171


Statement
 

pdf   zip

thehtml

Write a program that reads a series of lines, each of them containing a sequence of non negative integers, and prints as output the value of the sum of the first line that contains an even number of elements ending in 3. If there is no such line, the output will be -1.

For instance, for the input:

23 12 4 25
44 43 23 3 12 8
33 4 9 73 14
88 92 55

The output would be 133, because the third line contains 2 numbers ending in 3 (33 and 73), and the previous lines contained an odd number of such elements (1 and 3 respectively).
Thus, the third line is the first with an even number of elements ending in 3. The sum of the element of this line is 33+4+9+73+14 = 133

Input

The input is a series of lines with numbers. Each line contains at least one number.

Output

The output is the sum of the elements in the first line that happens to have an even number of elements ending in 3, or -1 if there is no such line.

Public test cases
  • Input

    23 12 4 25
    44 43 23 3 12 8
    33 4 9 73 14
    88 92 55

    Output

    133
    
  • Input

    23 12 4 25
    44 43 23 12 3
    88 92 55
    7 81 23 2 13 4

    Output

    235
    
  • Input

    4 28 45 23
    12 53 3 13 2 81
    3 4 5 6
    

    Output

    -1
    
  • Information
    Author
    Language
    English
    Official solutions
    Python
    User solutions
    Python