Starting Challenge
Premium Content - Free Preview
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
.
End of Free Content Preview. Please Sign in or Sign up to buy premium content.
Comments
Stefan
May 26, 10:36 AM2 2 8 2 2 14 2 2 68 is 90 not 68
Learneroo
May 26, 10:38 AM@Stefan, 4+4+16+4+4+28+4+4 = 68. You don't double it again when it's next to another 2.