Click here to Skip to main content
15,905,558 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Next coding challenge Pin
BillWoodruff30-Nov-16 17:26
professionalBillWoodruff30-Nov-16 17:26 
GeneralRe: Next coding challenge Pin
Jon McKee30-Nov-16 17:55
professionalJon McKee30-Nov-16 17:55 
AnswerRe: Next coding challenge Pin
Kornfeld Eliyahu Peter29-Nov-16 20:23
professionalKornfeld Eliyahu Peter29-Nov-16 20:23 
GeneralRe: Next coding challenge Pin
PIEBALDconsult30-Nov-16 2:58
mvePIEBALDconsult30-Nov-16 2:58 
AnswerRe: Next coding challenge Pin
Kirill Illenseer29-Nov-16 20:58
Kirill Illenseer29-Nov-16 20:58 
AnswerRe: Next coding challenge Pin
Mark_Wallace29-Nov-16 21:03
Mark_Wallace29-Nov-16 21:03 
JokeRe: Next coding challenge Pin
Kyle Moyer30-Nov-16 11:50
Kyle Moyer30-Nov-16 11:50 
AnswerRe: Next coding challenge Pin
kalberts30-Nov-16 2:31
kalberts30-Nov-16 2:31 
When we were students, a long, long time ago, one of my fellow students realized that he didn't master recursion very well - termination conditions in particular. So he defined a simple programming challenge for himself:

The program should draw a vertical zigzag line of asterisks on the printer (this was in the age of line printers): A count of spaces reflecting the recursion depth, with a "*" at the end. Each function call creates one such line, nothing else.

Now, at the top, "main()" level, he would call the recursive function with an argument MaxRecursionDepth to which the recursion should go directly when started (creating a slanted line of asterisks), an argumment IntermediateRecursionDepth to which the recursion should unroll (continuing the line, slanting the other way, but not all the way back). Then, it should recurse deeper again to MaxRecursionDepth and unroll to IntermediateRecursionDepth, reapeated as many times as indicated by the third agument, NumberOfPeaks, before unrolling to complete the program.

The printout should look like a tipped-over contour of a row of mountain peaks separated by valleys, the peak height, number of peaks and valley depths given by the three arguments.

If you have been writing recursive functions every day the last ten years, this is quite trivial. But if you are a student who heard the term 'recursion' for the first time last week, it takes some fiddeling to get those termination tests (and re-recursing tests) right.

And then, when you see the working solution, you won't understand why it took that much effort to get it correct Smile | :)
GeneralRe: Next coding challenge Pin
PIEBALDconsult30-Nov-16 2:59
mvePIEBALDconsult30-Nov-16 2:59 
GeneralRe: Next coding challenge Pin
kalberts30-Nov-16 4:00
kalberts30-Nov-16 4:00 
AnswerRe: Next coding challenge Pin
PIEBALDconsult30-Nov-16 3:14
mvePIEBALDconsult30-Nov-16 3:14 
AnswerRe: Next coding challenge Pin
Baraaaaaa30-Nov-16 3:29
Baraaaaaa30-Nov-16 3:29 
AnswerRe: Next coding challenge Pin
Jon McKee2-Dec-16 14:14
professionalJon McKee2-Dec-16 14:14 
GeneralTenacity, Perseverance Greater Than Genius? Pin
raddevus29-Nov-16 9:45
mvaraddevus29-Nov-16 9:45 
GeneralRe: Tenacity, Perseverance Greater Than Genius? Pin
Mark_Wallace29-Nov-16 9:57
Mark_Wallace29-Nov-16 9:57 
GeneralRe: Tenacity, Perseverance Greater Than Genius? Pin
raddevus29-Nov-16 10:09
mvaraddevus29-Nov-16 10:09 
GeneralRe: Tenacity, Perseverance Greater Than Genius? Pin
Mark_Wallace29-Nov-16 21:01
Mark_Wallace29-Nov-16 21:01 
GeneralRe: Tenacity, Perseverance Greater Than Genius? Pin
Chris Maunder29-Nov-16 12:05
cofounderChris Maunder29-Nov-16 12:05 
GeneralRe: Tenacity, Perseverance Greater Than Genius? Pin
Mark_Wallace29-Nov-16 21:12
Mark_Wallace29-Nov-16 21:12 
GeneralRe: Tenacity, Perseverance Greater Than Genius? Pin
Gary Wheeler30-Nov-16 0:47
Gary Wheeler30-Nov-16 0:47 
GeneralRe: Tenacity, Perseverance Greater Than Genius? Pin
raddevus30-Nov-16 1:55
mvaraddevus30-Nov-16 1:55 
GeneralRe: Tenacity, Perseverance Greater Than Genius? Pin
PIEBALDconsult29-Nov-16 12:37
mvePIEBALDconsult29-Nov-16 12:37 
GeneralRe: Tenacity, Perseverance Greater Than Genius? Pin
raddevus30-Nov-16 1:58
mvaraddevus30-Nov-16 1:58 
GeneralRe: Tenacity, Perseverance Greater Than Genius? Pin
Super Lloyd29-Nov-16 16:24
Super Lloyd29-Nov-16 16:24 
GeneralRe: Tenacity, Perseverance Greater Than Genius? Pin
raddevus30-Nov-16 2:01
mvaraddevus30-Nov-16 2:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.