Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,193,942 members, 7,952,794 topics. Date: Thursday, 19 September 2024 at 01:11 AM |
Nairaland Forum / Science/Technology / Programming / Coding Challenge 5: Substring Generator (4872 Views)
Mini Web Application Coding Challenge For Programmers / Java Coding Challenge: Task Scheduler / Coding Challenge 3: Sum Of Primes (2) (3) (4)
Coding Challenge 5: Substring Generator by Fayimora(m): 1:46pm On Jul 07, 2011 |
Implement using "r", "ru", "rum", "u", "um", "m", "" Goodluck |
Re: Coding Challenge 5: Substring Generator by GoodMuyis(m): 5:43pm On Jul 13, 2011 |
Correction sir |
Re: Coding Challenge 5: Substring Generator by Fayimora(m): 5:44pm On Jul 13, 2011 |
What correction? |
Re: Coding Challenge 5: Substring Generator by GoodMuyis(m): 8:17pm On Jul 13, 2011 |
Can this be usefull |
Re: Coding Challenge 5: Substring Generator by Fayimora(m): 8:49pm On Jul 13, 2011 |
Nope incorrect |
Re: Coding Challenge 5: Substring Generator by tundebabzy: 2:11pm On Jul 15, 2011 |
with python code:
If you must have a recursion:
Edit:
|
Re: Coding Challenge 5: Substring Generator by Fayimora(m): 2:40pm On Jul 15, 2011 |
Errrm unfortunaely i realy dont know python so what was ur result with the word 'rum' and 'fayimora' |
Re: Coding Challenge 5: Substring Generator by tundebabzy: 9:05am On Jul 16, 2011 |
sorry, nairaland-bot refused to inform me that you had replied no-recursion: rum---------------> r ru rum u um m "" fayimora---------> f fa fay fayi fayim fayimo fayimor fayimora a ay ayi ayim ayimo ayimor ayimora y yi yim yimo yimor yimora i im imo imor imora m mo mor mora o or ora r ra a "" iterative recursion: rum---------------> r u m ru um rum "" fatimora---------> f a y i m o r a fa ay yi im mo or ra fay ayi yim imo mor ora fayi ayim yimo imor mora fayim ayimo yimor imora fayimo ayimor yimora fayimor ayimora fayimora "" P.S i've edited my post to take care of some redundancies |
Re: Coding Challenge 5: Substring Generator by Fayimora(m): 8:23pm On Jul 16, 2011 |
Cool |
Re: Coding Challenge 5: Substring Generator by Fayimora(m): 8:56am On Aug 14, 2011 |
So just 1 person was able to solve this, wow! |
Re: Coding Challenge 5: Substring Generator by Beaf: 11:03am On Aug 14, 2011 |
. |
Re: Coding Challenge 5: Substring Generator by Beaf: 11:51am On Aug 14, 2011 |
I almost made a mock of myself rushing to post something I'd done in notepad on a PC without dev tools. Thank God I noticed the errors immediately I posted, otherwise man for no fit talk for programming section again! Here goes (in C#): void GetAllSubstrings(string input, int startIndex) |
Re: Coding Challenge 5: Substring Generator by Mobinga: 10:40pm On Aug 14, 2011 |
public class arr { public void mm(){ String s = "mobinga"; StringBuilder ss = new StringBuilder(s); String sss = ss.reverse().toString(); // System.out.println(ss.reverse()); rec(sss,s); } public void rec(String sss,String s ){ for(int e = sss.length(); e>=0; e--){ StringBuilder lll = new StringBuilder(sss.substring(e)); String ssss = lll.reverse().toString(); System.out.println(ssss); } for(int z = 1; z<=s.length(); z++){ StringBuilder lll = new StringBuilder(sss.substring(z)); String ssss = lll.reverse().toString(); System.out.println(s.substring(z)); } } public static void main(String [] args){ arr psvm = new arr(); psvm.mm();}} Output :: m mo mob mobi mobin mobing mobinga obinga binga inga nga ga a ----------------- Non recursive -- //Would do that later. ----------------- |
Re: Coding Challenge 5: Substring Generator by iGravity(m): 7:23pm On Aug 15, 2011 |
Why break your head on recursion when what you need is a substring generator? In Ruby . . . def substring_generator str 1.upto(str.split('').size).each do |n| pp str.split('').combination(n).to_a end end Less clutter, more readable, gets the job done! |
Re: Coding Challenge 5: Substring Generator by Fayimora(m): 7:30pm On Aug 15, 2011 |
Thats why its a challenge! Its not an assignment so yeah Recursion |
Re: Coding Challenge 5: Substring Generator by iGravity(m): 7:39pm On Aug 15, 2011 |
Fayimora: this is the more reason to assume that this is some assignment and you're looking for the best solution. My opinion though -- it may not necessarily be right |
Re: Coding Challenge 5: Substring Generator by Fayimora(m): 7:50pm On Aug 15, 2011 |
Again its a challenge! AM not looking for the best solution but challenging you to recursion. |
Re: Coding Challenge 5: Substring Generator by Beaf: 7:59pm On Aug 15, 2011 |
Fayimora: So far, my solution is the only recursive one that produces the expected result, you can test it. Bros, abeg gif me di trophy na! Lol! |
Re: Coding Challenge 5: Substring Generator by Fayimora(m): 8:03pm On Aug 15, 2011 |
Ok tell me How to run it. I know nothing about c# |
Re: Coding Challenge 5: Substring Generator by Beaf: 10:41pm On Aug 15, 2011 |
Fayimora: How about C++? This is the same code in a simple C++ class:
You can call it like so: SubstringGen substringGen; |
(1) (Reply)
Learn PHP & MYSQL The Fast Way. / What Laptop Spec Is Good 4 Programming And Graphic Design? / How Do You Market Your Self As A Developer
(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. 45 |