Rules of the Gig :
- You can use any programming language to write the program.
- The code should be available on Github on a public repo. Better to make this as a single file program.
- When copy pasted from Github into https://www.codechef.com/ide the code should execute and return the results.
- Share the link to github in the comments.
- If two or more solutions are very similar and are written in the same programming language then the first comment will be the contender.
- If there are two solutions let us be civilised and post in comments if there are any flaws. I an not sure how this will work but we can figure this out as we go forward.
- All the liquid SBD will be awarded to the winner.
- Each solution will get an 100% up-vote from me.
- Resteem and upvote to increase the stakes of the competition.
Problem Statement
The program should read a input string that contains text and break it further into paragraphs, sentences and words.
Input:
First sentence of first paragraph.
Second sentence of first paragraph.
First sentence of second paragraph.
Second sentence of second paragraph.
Output:
First sentence of first paragraph. Second sentence of first paragraph.
First sentence of first paragraph.
First
sentence
of
first
paragraph.
Second sentence of first paragraph.
Second
sentence
of
first
paragraph.
First sentence of second paragraph. Second sentence of second paragraph.
First sentence of second paragraph.
First
sentence
of
second
paragraph.
Second sentence of second paragraph.
Second
sentence
of
second
paragraph.
If you have any questions about the problem statement do let me know in comments and I will try to clarify your doubts.
Trying this challenge: https://repl.it/KOVc/1
Since each layer follows the same pattern I made a general purpose splitting function that returns an array and allows a block for each child. At the end I flatten it all and print it.
Since exact delimiters were not specified I assumed from the input. This will need to be more sophisticated for real world usage...
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Nice and clean code man. I'm considering learning ruby on the side. Looks like a nice language to learn.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
This post received a 2.7% upvote from @randowhale thanks to @gokulnk! For more information, click here!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
The site you mention doesn't allow JavaScript input, probably because you don't need a website to parse JS (the developer console in any browser is enough). Do you still accept JavaScript solutions?
Also, in which format do you want the output? Should it be with the horizontal lines between it, like in your posts? Or just single line returns like this:
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Yes. Please share a link to the website where your code can be run. We can update the post with the link that website.
Singe line results should do. It was added just for the sake of clarity. We can accept both as answer I think.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Sorry, I was in a meeting. Took me about 10 minutes to code this, I can make the code prettier if you like but I think it does exactly what you asked. https://jsfiddle.net/zpyn1f56/1/
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
@pilcrow Great. Upvoted with 100 %. Can you retry doing this using recursion? That way we can just pass the delimiters and the level, the program should break it upto nth level.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
The delimiter changes each time, so recursion doesn't seem like a good option to me. In fact, the only difference between a paragraph, a line and a word is which delimiter it uses. If I did this recursively I can't think of a way to reliably break up the content into increasingly smaller chunks.
By the way, is this a contest or your homework I'm solving? ;)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
I already have used this in https://steemit.com/languages/@gokulnk/learning-german-using-google-spreadsheets
I wanted to know if there was a better way of doing this. Hence posted this as a contest.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
@pilcrow do let me know if you would be interested in collaborating on https://steemit.com/qa/@gokulnk/q-a-site-based-on-steem-brainstorming. If you are interested we can catch up on steemit chat.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Sorry, I'm already working on two Steemit apps and one other app in my free time (plus 40 hours a week programming for my job). I think I won't have time to collaborate at least until 2018 :)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit