Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,194,214 members, 7,953,789 topics. Date: Friday, 20 September 2024 at 06:23 AM |
Nairaland Forum / Science/Technology / Programming / QUIZ: How Many Lines Of Code Can You Use To Reverse A List (4777 Views)
30 Days Of Code {April 19 - May 18} / 100 Days Of Code Challenge / How Many Lines Of Code Run Nairaland? (2) (3) (4)
Re: QUIZ: How Many Lines Of Code Can You Use To Reverse A List by Kodejuice: 8:25am On Jun 08, 2017 |
|
Re: QUIZ: How Many Lines Of Code Can You Use To Reverse A List by antieverything(m): 11:38am On Jun 08, 2017 |
bash shld do the trick |
Re: QUIZ: How Many Lines Of Code Can You Use To Reverse A List by orimion(m): 10:16pm On Jun 08, 2017 |
Two lines
|
Re: QUIZ: How Many Lines Of Code Can You Use To Reverse A List by Sirnuel: 2:38pm On Jun 10, 2017 |
//////JAVA import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Main { public static void main(String[] args) { // write your code here List<Integer> myList= new ArrayList<Integer>(Arrays.asList(9, 2, 5, 4, 12, 7, 8, 11, 9, 3, 7, 4, 12, 5, 4, 10, 9, 6, 9, 4)); List<Integer> reverseList = new ArrayList<>(); for(int i = myList.size()-1; i >= 0 ; --i){ reverseList .add(myList.get(i)); } //this line dosent count either it is used to print out the reversed list System.out.println(reverseList); } } |
Re: QUIZ: How Many Lines Of Code Can You Use To Reverse A List by nsimageorge(m): 7:26pm On Jun 11, 2017 |
This is interesting... In PHP $array = array(1, 2, 3); for($i=sizeof($array)-1; $i>=0; $i--){echo $array[$i];} 2lines |
Re: QUIZ: How Many Lines Of Code Can You Use To Reverse A List by badthinds: 9:57pm On Jul 05, 2017 |
webdeveloperqx:Nice one...but your code didn't show clearly what you reversed. Ie. Where is the reversed one? |
Re: QUIZ: How Many Lines Of Code Can You Use To Reverse A List by Nobody: 12:32pm On Jul 06, 2017 |
3 Lines with C# List<int> yourList = new List<int>() {1,2,3,4,5}; yourList.Reverse(); yourList.ForEach(items => Console.Write(items)); |
Re: QUIZ: How Many Lines Of Code Can You Use To Reverse A List by badthinds: 2:05pm On Jul 06, 2017 |
Febup:Clean code, but you used inbuilt ".Reverse()". Not allowed. |
Re: QUIZ: How Many Lines Of Code Can You Use To Reverse A List by Nobody: 6:58pm On Jul 06, 2017 |
Take this: now 2 Lines with C# List<int> list = new List<int>() { 1, 2, 3, 4, 5 }; for (int i = (list.Count - 1); i >= 0; i--){Console.WriteLine(list.ToArray()[i].ToString());} |
Re: QUIZ: How Many Lines Of Code Can You Use To Reverse A List by Sync201(m): 11:42pm On Jul 06, 2017 |
#python just 1lines L=['a','b','c','d'] ; print(L[::-1]) <<<Output>>> ['d','c','b','a'] |
Re: QUIZ: How Many Lines Of Code Can You Use To Reverse A List by badthinds: 6:38pm On Jul 08, 2017 |
Sync201: Lol. If you read the first post...after semicolon...like the one you used, its a line++ |
Re: QUIZ: How Many Lines Of Code Can You Use To Reverse A List by Nobody: 9:58pm On Jul 08, 2017 |
At op. Java code is 4 lines, you need to ignore the framework. |
Re: QUIZ: How Many Lines Of Code Can You Use To Reverse A List by badthinds: 8:45am On Jul 09, 2017 |
Febup: I know, but what we want is something anyone can copy and run successfully. Its possible to do it without all those inclusion |
Re: QUIZ: How Many Lines Of Code Can You Use To Reverse A List by Nobody: 11:48am On Jul 09, 2017 |
badthinds: In that case you will need to add 9 more lines to JavaScript as you cannot run JavaScript and display your output without the lines below. This will also apply to all the other languages as you will have to make some language declarations before you can run your code. <HTML> <head> <script type="text/javascript"> </script> </head> <body> <div> </div> </body> </html> |
Re: QUIZ: How Many Lines Of Code Can You Use To Reverse A List by badthinds: 5:04pm On Jul 09, 2017 |
Febup:How about the nodeJs console Lol. The examples you gave, eg in the case of javascript, all those html,body stuffs ain't necessary (the <script> is only necessary if its gonna be executed by a browser)...above all, they are not part of Javascript. But anyway, all those with....eg java codes, same principles would be followed in ranking...so, it is fair. |
Re: QUIZ: How Many Lines Of Code Can You Use To Reverse A List by Nobody: 7:59pm On Jul 09, 2017 |
badthinds: OK in that case you'll need to add 7 more lines for JavaScript. <HTML> <head> <script type="text/javascript"> /* Your code goes hear */ alert('Your Results'); </script> </head> </html> |
Re: QUIZ: How Many Lines Of Code Can You Use To Reverse A List by orimion(m): 3:37am On Jul 10, 2017 |
Febup:Its like you didn't read it well, he said badthinds:all those tags are not part of Javascript, they are HTML just fire up your browser and go to console in the dev tool or better still the nodejs repl 1 Like |
Re: QUIZ: How Many Lines Of Code Can You Use To Reverse A List by Nobody: 11:11am On Jul 10, 2017 |
orimion: My bad. |
Re: QUIZ: How Many Lines Of Code Can You Use To Reverse A List by adejumoadeoluwa(m): 7:44am On Jul 11, 2017 |
reverse = lambda x: x[::-1] #one liner bitch! |
Re: QUIZ: How Many Lines Of Code Can You Use To Reverse A List by bjboss(m): 3:54pm On Jul 25, 2017 |
Re: QUIZ: How Many Lines Of Code Can You Use To Reverse A List by Irelokeh(m): 5:27pm On Jul 25, 2017 |
Here's mine with JAVA import java.util.*; public class Main { public static void main(String[] args) { int set [] = {1,2,3,4,5,8,5,5}; int a = set.length; for (int i=0; i<=set.length-1; i++) { System.out.println(set[a-=1]); } } } |
Re: QUIZ: How Many Lines Of Code Can You Use To Reverse A List by badthinds: 10:42am On Jul 27, 2017 |
adejumoadeoluwa:Nice one Motherfcuker! |
Re: QUIZ: How Many Lines Of Code Can You Use To Reverse A List by badthinds: 10:46am On Jul 27, 2017 |
bjboss:LOL. I was looking at the code and grinding my teeth...but there was nothing I could hold against it being technically 1 line or not. 1 Like |
Re: QUIZ: How Many Lines Of Code Can You Use To Reverse A List by DevDenky: 6:33am On Jul 28, 2017 |
Import Java.util.*; public class Main{ public static void main(String[] args) { List<Integer> list = Arrays.asList(1,2,3,4); for(int x=list.size() ; x>0; x- -) System.out.println(list[x]); } } 1 Like |
Re: QUIZ: How Many Lines Of Code Can You Use To Reverse A List by harryobas: 10:48am On Aug 14, 2017 |
In Ruby: def reverse_list(list) idx = -1 reversed_list = [] list.length.times {reversed_list << list[idx]; idx -= 1} reversed_list end |
Re: QUIZ: How Many Lines Of Code Can You Use To Reverse A List by ACFreeHost: 11:11pm On Oct 08, 2017 |
Are you a website developer or a web designer and you need a reliable hosting server provider to host your website for FREE and Adverts FREE? That's why ACFreeHost is here to make that possible for you Publishers, just all you need is to visit www.acfreehost.com and register then you are good to go. No Adverts on your sites, No disk limite, No bandwidth limite e.t.c. Don't worry all are FREE and if you have any question their pleased to assist you. So visit www.acfreehost.com and register Now.!! VISIT : [url]WWW.ACFREEHOST.COM[/url] |
We Are Recruiting Founding Team Members For Our Upcoming Startup! / Hire Me To Build A PHP Script For You / See Why You Cant Code ( Secret From Mark Zuckerberg)
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 64 |