0

Help needed :)

I would really appreciate it if you guys help me out with this: 1. Write a function that would return [4,3,8,6,16,12...192] 2. Write a function that would return 3 elements from an array that sum up to 0 Ex: Input = [6,-3,9,-2,-3,7,8...] Output = [6,-3,-3] 3. Assume A and B are two lines parallel to the x axis, write a function that would return the length of line C which is a line where A and B overlap Ex: A = (2,8) B = (4,10) Length of C = 4 Please write your answers in javascript or python. I have written mine but I would like to see a cleaner, more efficient way of writing them Here's mine https://code.sololearn.com/WWhi5l9k5Vmp/?ref=app

19th Aug 2019, 7:54 PM
Fernando Moceces
Fernando Moceces - avatar
2 Respostas
+ 3
You first function contains a useless if/else logic, this works also: Series=function(){ a=4; b=3; c=[]; while(b<2*192){ c.push(a); a*=2 c.push(b); b*=2 } return c }
19th Aug 2019, 8:10 PM
Paul
Paul - avatar
0
Paul Jacobs thank you for noticing that redundancy
19th Aug 2019, 9:40 PM
Fernando Moceces
Fernando Moceces - avatar