[CHALLENGE]🏆 Print the following series | SoloLearn: Learn to code for FREE!

+12

# [CHALLENGE]🏆 Print the following series

📑 Description: Print numbers in alternating order. You should take a number as input : >> 5 And your output should be : >> [0,5,1,4,2,3] Let's take another input as : >> 10 And, your output should be: >> [0,10,1,9,2,8,3,7,4,6,5,5] ✨ Hint: Every two consecutive numbers add up to give the input 🔖 Note: Your output list should have even number of terms Best of luck 👍 # Happy coding

12/5/2017 9:51:40 AM

#RahulVerma

+33

//here is my try ☺ //no loops used ☺ //1 loop , 2 loop methods are in comment 😁 //works for +ve as well as -ve https://code.sololearn.com/c9DXjEre07Mx/?ref=app

+15

My try: https://code.sololearn.com/Wu39Wt0FUEN4/?ref=app

+14

Here's Java oneliner : https://code.sololearn.com/coZ30c65ex38/?ref=app

+12

My try https://code.sololearn.com/c62zc9953RaZ/?ref=app

+12

Here is my late Python code 🙌🙌 https://code.sololearn.com/c6djpgV7EKSG/?ref=app

+11

https://code.sololearn.com/cKV6T6xnho4u/?ref=app

+11

Wow, I'm late 😩. But challenge accepted 😁👊

+11

https://code.sololearn.com/cDHONXh3604L/?ref=app #one-line

+10

Here's my try in c++: https://code.sololearn.com/c533DeTkBLA4/#cpp Hope you like it :D

+9

https://code.sololearn.com/cAGdDbOyzd5f/?ref=app

+7

Here is code for -ve integers as well as +ve integers... https://code.sololearn.com/c7H6zO3RfFQf/?ref=app

+6

https://code.sololearn.com/cHj46Wn9ebj9/?ref=app

+6

https://code.sololearn.com/c6URikzTr1ej/?ref=app I created the codes and a full explanation of my entire logic throughout all the process. Enjoy it.

+6

@#RahulVerma, Thanks for clarifying, will try to get it done ;) (Edit) Here's my attempt at the challenge: https://code.sololearn.com/c49QHpiyN1TA/?ref=app

+6

Check Mine !! https://code.sololearn.com/c6CLINj1vr9I/?ref=app

+5

#include <iostream> using namespace std; int main() { int n; cin>>n; for(int i=0,j=n;(i<=n/2)&&(j>=n/2);i++,j--) { cout<<i<<" "<<j<<" "; } return 0; }

+5

https://code.sololearn.com/cvQc2G6fiYhH/?ref=app

+5

https://code.sololearn.com/W3TpSCB1htu0/?ref=app

+5

https://code.sololearn.com/c54RMrG5LKWt/?ref=app

+5

Sorry, just wanted confirmation, on the first example (5) we have 6 items, including zero. But on the second example (10), I see a twin of five, at the end of the list, which means it was not merely a number sequence. My question is, those twins, when do we need to have/create a twin number? like if they are at the center of the list? Thanks :)