Share your repls and programming experiences

← Back to all posts
papacoding (1)

Instructions from your teacher:
Given the array of numbers. Create another array called computedNumbers. computedNumbers should multiply each element in the numbers array by the next element. The last element should be multiplied by the first.

e.g. If numbers was equal to:
[3, 1, 4, 2]

computedNumbers should equal [3 x 1, 1 x 4, 4 x 2, 2 x 3] which is:
[3, 4, 8, 6]

Replace the comments with your code.

HINT: In Swift, multiplication is done with the asterisk symbol. e.g. 3 x 4 would be:
3 * 4

1. You should not have to do the calculations yourself, it should be done by the code.
2. You are not allowed to type the numbers 45, 73, 195 or 53 in your solution code.
3. computedNumbers should be created as a variable named exactly as you see in the print statement. Do not change the rest of the code.

papacoding (1)

Just starting on Swift. and stuck on this exercice....About to give it up all. Please help I am suffering 😰

VMTU (37)

@papacoding Hmm... Let me see, I am not really a swift expert but let me see. I will give you repl

papacoding (1)

@VMTU amazing I cannot thank you enough. you really the star of the day, lightning my day. Thanks for your time

papacoding (1)

@VMTU Seriously are you 8 ??? 😳