Next coding challenge
-
It maybe too easy, but in honor of the ongoing Chess Word Championship (for humans and for chess engines) we may do the 8 queen problem...
Skipper: We'll fix it. Alex: Fix it? How you gonna fix this? Skipper: Grit, spit and a whole lotta duct tape.
I did N-Queens a few years back, but not the ability to determine which solutions are distinct/unique. So include the above suggestion of rotating an NxN matrix, add flipping of the matrix, and then you've got something. :cool:
-
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 :-)
Except we wouldn't use recursion, would we? :suss:
-
Friday's coming up. Any thoughts on our next coding challenge? We need a simple task, easily coded, and easily tested.
cheers Chris Maunder
Implementing games is good exercise. The first game I implemented (in BASIC-plus on a PDP-11 in 1983) was Master Mind. How about a function that determines the black/white counts for two arrays of items -- not just arrays of four colors, but two
IList<IEquatable>
s of equal size. (Well, maybe don't state it so .net-specific.) -
Friday's coming up. Any thoughts on our next coding challenge? We need a simple task, easily coded, and easily tested.
cheers Chris Maunder
adventofcode.com will begin tomorrow.
-
Except we wouldn't use recursion, would we? :suss:
-
How about "Do something to make my life* easier"? * Mine, that is.
I wanna be a eunuchs developer! Pass me a bread knife!
Need someone to finish that novel for you? ;P
-
I know I wouldn't want to spend all my time in a week looking over 20+ KLOC from 15+ entries, testing them to ensure they meet the requirements, and then using some metric to rate which came out on top. Depending on complexity that might be a restrained estimate as well X|
Hi, Jon, I would distinguish the relative difficulty of a problem from whether or not a problem inherently demands a lengthy solution.
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008
-
Hi, Jon, I would distinguish the relative difficulty of a problem from whether or not a problem inherently demands a lengthy solution.
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008
Very true. Difficulty does not necessarily equate to lines of code. Personally, I come up with very few ideas when attempting to meet the criteria of difficult while staying within reasonable amounts of required code. That aren't exclusively mathematics that is - gotta mix it up. I'm all for it though if people have ideas :thumbsup:
-
Friday's coming up. Any thoughts on our next coding challenge? We need a simple task, easily coded, and easily tested.
cheers Chris Maunder
-
Idea: Rotating an NxN matrix in-place, maybe? Question: What exactly are the answers graded on? Creativity, complexity, simplicity, or some other metric?
I have come to the conclusion that (depending on what you are actually doing) you don't need to actually rotate an NxN matrix -- you need only apply a transformation to the X and Y coordinates of the desired cell to access a cell as if the matrix had been rotated. :cool:
-
I have come to the conclusion that (depending on what you are actually doing) you don't need to actually rotate an NxN matrix -- you need only apply a transformation to the X and Y coordinates of the desired cell to access a cell as if the matrix had been rotated. :cool: