Starting Challenge


Collapse Content

This is a basic challenge to test out the interface and your if statement.

Challenge

A 2-sum is the sum of a list of numbers, but every number that's next to a 2 is counted twice. Given a list of numbers, print out their 2-sum.

For example, when given 1 2 3 4 as input, print 14, the sum of the numbers with 1 and 3 counted twice.

Details

As mentioned here, the challenges provide Standard Input and you need to print your solution to the output (with System.out.println) . You are provided with boilerplate code which processes the input and passes it to the method doStuff.

In these contest challenges, you can run the code on "Test input" and see the results. To pass the challenge, you need to run the code on hidden "Contest Input", which will just return Correct or Incorrect.

Input
The first line will contain T, the number of test cases. Each test case contains 2 lines:

  • N - the number of elements in a list.
  • N numbers follow.

Output
Print out the 2-sum of each list on its own line.

Challenge

Find and print the 2-sum of each list.

Please sign in or sign up to submit answers.

Alternatively, you can try out Learneroo before signing up.

Comments

Contact Us
Sign in or email us at [email protected]