Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,151,334 members, 7,811,974 topics. Date: Monday, 29 April 2024 at 03:29 AM |
Nairaland Forum / Science/Technology / Programming / Sorting List Of Numbers And Strings: Simple Puzzle (9444 Views)
Sorting Out A Simple Text Dictionary With PHP / Sorting Algorithms / How To Sorting Tables With Vb.6 (2) (3) (4)
Re: Sorting List Of Numbers And Strings: Simple Puzzle by pak: 5:12am On Jan 04, 2013 |
InvertedHammer: This is a programming question for beginners! Omo elefo , who ask you ? ekt_bear didn't ask whether it was for novices or superman, all he said was solve it !!! |
Re: Sorting List Of Numbers And Strings: Simple Puzzle by ektbear: 6:03am On Jan 04, 2013 |
Heh, funny that this made the front page several months after. |
Re: Sorting List Of Numbers And Strings: Simple Puzzle by eaglechild: 6:03am On Jan 04, 2013 |
Javanian:You realise i used the word 'very' right. Besides front page topics should appeal to a wider range of audience. If i come out ranting about my subspeciality in medicine, i wonder how many people will contribute. |
Re: Sorting List Of Numbers And Strings: Simple Puzzle by lordZOUGA(m): 7:52am On Jan 04, 2013 |
jacob05: @lordZOUGA i hail ooooothis code breaks if the input contains zero |
Re: Sorting List Of Numbers And Strings: Simple Puzzle by jacob05(m): 7:57am On Jan 04, 2013 |
pak: ekt_bear, I feel like punching you for depriving me of my sleep really. Saw this as I was about to hit the sack and couldn't blink until I cracked it.Well, thanks bro. My C++ version could have been 'elegant' as you claim your solution is if C++ had provided robust string processing classes like python does (li.split() ) and also a portable mechanism to check for type (s.isdigit() python provided). Guessed those took the glory . I'm still waiting for a better solution though |
Re: Sorting List Of Numbers And Strings: Simple Puzzle by jacob05(m): 8:33am On Jan 04, 2013 |
lordZOUGA:Nice catch boss! Fixed
|
Re: Sorting List Of Numbers And Strings: Simple Puzzle by jacob05(m): 8:48am On Jan 04, 2013 |
pastebin.com/rWhEvaYw |
Re: Sorting List Of Numbers And Strings: Simple Puzzle by PrinceNN(m): 10:14am On Jan 04, 2013 |
pak: ekt_bear, I feel like punching you for depriving me of my sleep really. Saw this as I was about to hit the sack and couldn't blink until I cracked it. My logic is undeniable! I can evn make it shorter.... Lmao @ GDP of Nigeria.... |
Re: Sorting List Of Numbers And Strings: Simple Puzzle by Nobody: 2:50pm On Jan 04, 2013 |
Re: Sorting List Of Numbers And Strings: Simple Puzzle by lordZOUGA(m): 3:04pm On Jan 04, 2013 |
and then the contest turns to a test of code length.. |
Re: Sorting List Of Numbers And Strings: Simple Puzzle by PrinceNN(m): 3:07pm On Jan 04, 2013 |
omo_to_dun: Haba! You removed all other lines leaving only the your method and cheated your way to 15 lines. l = "car truck 8 4 bus 6 1" |
Re: Sorting List Of Numbers And Strings: Simple Puzzle by lordZOUGA(m): 7:15pm On Jan 04, 2013 |
another C++ implementation http://pastebin.com/KbgsKFiG |
Re: Sorting List Of Numbers And Strings: Simple Puzzle by Nobody: 8:17pm On Jan 04, 2013 |
Re: Sorting List Of Numbers And Strings: Simple Puzzle by PrinceNN(m): 11:20pm On Jan 04, 2013 |
omo_to_dun: @PRINCEowky...true that |
Re: Sorting List Of Numbers And Strings: Simple Puzzle by pak: 12:47am On Jan 05, 2013 |
lordZOUGA: and then the contest turns to a test of code length.. Not a big deal bro, Many of the guys on the thread have already gotten the logic of the solution and prince did it in less than 30 mins to boot. It was just a way of introducing more fun to the whole process. No biggie ! I don't know if you are a pythonista, so maybe just maybe you might not understand the intense pleasure of writing elegant minimalist code. I got hooked on the whole concept bout four years back when I saw a contest on the web to write the shortest code to extract youtube videos as flv. Definitely, Perl came first (with about just 2 lines or so), awk followed and Python was third. |
Re: Sorting List Of Numbers And Strings: Simple Puzzle by pak: 12:59am On Jan 05, 2013 |
omo_to_dun: @PRINCE Bro, the reason why I didn't mention yours was cos as much as your logic might have been right. The code still didn't meet up with what ekt_bear specified, ability to receive input from stdin and output to stdout, for obvious reasons l = "car truck 8 4 bus 6 1" @Prince - cool bro - 15 lines, now let me see how far I can refactor mine |
Re: Sorting List Of Numbers And Strings: Simple Puzzle by pak: 1:52am On Jan 05, 2013 |
I went on an overdrive and came up with a solution that will definitely take something special to beat. 6 lines !!!. The only thing I can say is, PYTHON IS SWEET You can check it out ! li = raw_input("enter ".split(' ') |
Re: Sorting List Of Numbers And Strings: Simple Puzzle by PrinceNN(m): 3:04am On Jan 05, 2013 |
pak: I went on an overdrive and came up with a solution that will definitely take something special to beat. lool i have similar code (6lines) too...was just waitn for someone to up the limit ....but id give it to you as urs contained less characters |
Re: Sorting List Of Numbers And Strings: Simple Puzzle by Fayimora(m): 3:41am On Jan 05, 2013 |
I was solving this with Java but stopped when I really understood the question. Scala and Functional Programming FTW!!! https://gist.github.com/4459253 Time spent: 10-12mins |
How Do I Edit Datagrid ? / Teach Yourself To Code / Is Anything Better Than The Netbeans Ide?
(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. 43 |