(## CIRCULARY-MOVING-SUM##)merry go round//how's that sound ?// | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 7

(## CIRCULARY-MOVING-SUM##)merry go round//how's that sound ?//

input 1::: array of some integers("+ve or -ve") input 2::: a positive integer 'n' eg1--(task and outputs)--> array= [1,3,4] n=5 --1+3+4+1+3 = 12 --3+4+1+3+4=15 --4+1+3+4+1=13 output array= [12,15,13] eg2--(task and outputs)--> array= [1,6,7,8] n=3 --1+6+7=14 --6+7+8=21 --7+8+1=16 --8+1+6=15 output array= [14,21,16,15] eg3--(task and outputs)--> array= [4,5] n=5 --4+5+4+5+4=22 --5+4+5+4+5=23 output array= [22,23] SAMPLE INPUT: 2 -4 6 -7 5 SAMPLE OUTPUT: print the input [ -1 , -7, 3, -10] ## Thanks

28th Aug 2017, 5:35 PM
sayan chandra
sayan chandra - avatar
16 Answers
+ 4
Here you go. Checks for valid input. Negatives come into play, but if they did, it would calculate correctly. https://code.sololearn.com/cNcY5xSvmGg0/?ref=app
28th Aug 2017, 6:33 PM
Vari93
Vari93 - avatar
+ 3
https://code.sololearn.com/Wo4mdyjbvXn0/#js Hello, thanks for the challenge. :)
28th Aug 2017, 7:05 PM
Mehmet
Mehmet - avatar
+ 3
mine https://code.sololearn.com/WES8XsiH0sgQ/?ref=app note: in the second example the sum of 8+1+6 is 15 ☺ note2: if you put the steps as array's length, the resultant array will have all the same terms
28th Aug 2017, 7:47 PM
ysraelcon
ysraelcon - avatar
+ 3
@ysraelcon Actually any number that is a multiple of input array's length will give the same result. Nice catch though 👍
28th Aug 2017, 8:15 PM
Mehmet
Mehmet - avatar
29th Aug 2017, 10:23 AM
m abrate
m abrate - avatar
+ 2
Here's mine, https://code.sololearn.com/ccQG23fFRN4K/?ref=app Edit: simplified the two functions I had into one since the logic I went with didn't really need such structure.
28th Aug 2017, 8:46 PM
Edgar Garrido
Edgar Garrido - avatar
1st Sep 2017, 9:37 AM
Julian Fechner
Julian Fechner - avatar
28th Aug 2017, 7:57 PM
Sivan Tal
Sivan Tal - avatar
+ 1
Here is my take, Please have look and let me know your suggestions https://code.sololearn.com/cgUs3kVC2T2u/#py
28th Aug 2017, 8:06 PM
Balaswamy
Balaswamy - avatar
+ 1
Here's my C# implementation ✌ LINQ One-Liner〰 Enumerable.Range(0, len) .Select(n => Enumerable.Range(n, count) .Sum(i => numList[i % len])) Once again, I must confess that I love LINQ so much. Enjoy! https://code.sololearn.com/cC5Km6K82ysQ/?ref=app
29th Aug 2017, 3:31 AM
Zephyr Koo
Zephyr Koo - avatar
0
Hey, 8+1+6=14 ??? I don't think so...
28th Aug 2017, 7:52 PM
Sivan Tal
Sivan Tal - avatar
29th Aug 2017, 5:13 PM
Milan Augustin
Milan Augustin - avatar
0
https://code.sololearn.com/Wc4KtRN62C6A/?ref=app
30th Aug 2017, 9:42 PM
Syahmi Said
Syahmi Said - avatar
- 1
HERES A NEW CHALLENGE CHECK IT AND TRY IF YOU WANT https://www.sololearn.com/discuss/793924/?ref=app
17th Oct 2017, 3:18 PM
sayan chandra
sayan chandra - avatar