July 2018
Intermediate to advanced
400 pages
12h 14m
English
For this advanced challenge, begin with this list of values:
val valuesToAdd = listOf(1, 18, 73, 3, 44, 6, 1, 33, 2, 22, 5, 7)
Using a functional programming approach, perform the following operations on the valuesToAdd list:
Exclude any number less than 5.
Group the numbers in pairs.
Multiply the two numbers in each pair.
Sum the resulting products to produce a final number.
The correct result is 2,339. Walking through each step, here is what the data should look like along the way:
Step 1: 1, 18, 73, 3, 44, 6, 1, 33, 2, 22, 5, 7
Step 2: 18, 73, 44, 6, 33, 22, 5, 7
Step 3: [18*73], [44*6], [33*22], [5*7]
Step 4: 1314 + 264 + 726 + 35 = 2339
Notice that step 3 groups the list into sublists ...
Read now
Unlock full access