r/programmingchallenges • u/babygame • Jun 01 '11
Coloring a grid
Make a program to color in the squares of an (n x m) grid (with some number of colors > 2) such that no two same colors touch.
There is a 'brute force' way, and (at least one) more 'elegant' solution as well.
Edit: I didn't specify-- try one that will output a different pattern each time. It's a nicer problem, I think :)
21
Upvotes
View all comments
Show parent comment
1
u/StoneCypher Sep 08 '11
Not enough to know the difference between optimized brute force and never-was-brute-force-in-the-first-place, apparently.
You strike me as one of those people who thinks that everything is a specialized case of random brute force sampling. The equivalent kind of idiot in computer science will point out that essentially everything is turing complete; it's as meaningless a non-observation as yours is.
Let me be perfectly clear with you. You're looking at a simple iteratative algorithm with the shuffle button turned on. THAT IS NOT WHAT BRUTE FORCE MEANS. Brute force means trying every possible end result, not taking one measured step at a time.
Just because there's a technique which is well known to mathematicians doesn't mean you have correctly identified its use.
Here is a case example where you have not.
That you have made a mistake is not a case of my having gotten confused. You're just making a pile of unjustified assertions then presuming superiority when someone points out the critical logical errors underpinning your claim.
This is not rejection sampling because:
Rejection sampling is where you generate a complete answer at random, then measure it, and either throw it back into the pool or accept it. Its purpose is not to find answers, but rather to see the rate of rejection as a ratio.
You are 100% full of crap.
Logic: another field you shouldn't be pretending to understand. Ad hominem is not a fancy way to say insult, and I have not made any logic which is reliant on insults. This is simply incorrect.
Funny how you complain about insults, then insult in the same sentence. I have a word. It starts with "hypocri" and ends with "e". Can you find the missing letters?
Actually, it isn't. What you may have meant was "since the order of iteration can impact the neighbor workload." The critical (not crucial, get an english book please) element is actually the single-pass scan. Consider reading a book by Dijkstra.
I find this particularly hilarious since you tried to ask me if I could compute the workload of the algorithm, and it's becoming apparent that you cannot.
No it won't. Please take a breath and try it, instead of hand-waving about imaginary trap cases you set. In either of those cases there are a worst case of two neighbors; every cell can be filled with zero backtracking.
Maybe you missed that part where I told you the worst case wasn't a problem. Maybe you just are too far from being a mathematician to know how to find the worst case. Maybe for all your talk of what I don't get, you don't actually know how to measure the worst case and figure out how much work it is.
Does it bother you that you're wildly speculating about a well defined, easily bounded thing which earlier you were haughtily challenging others to find, then giving hilariously easy to beat examples which, if you had bothered to think them through, don't actually support you in any way?
I mean hell, if you just do a checkerboard then fill in the rest you're in a way worse position than the silly case you described, and it's still an under-one-second scan.
You just don't know what you're talking about.
I don't need to. I just found the worst case and tried that, which I told you before this response.
You aren't reading what's being said to you very successfully.
It's funny how you keep saying this, apparently blissfully unaware that it is completely wrong, and that the reason for that was already explained to you.
Looooolooooool.
You think this is SAT?
You aren't even enough of a mathematician to know the difference between the complexity of coloring contiguous maps and coloring arbitrary graphs?
C'mon, Jean-Claude. You said you could easily provide an example. I pulled your card, because you can't.
Instead of giving an example, you gave a link to an unrelated math problem that you think is the same thing, and thought you succeeded.
I'll say it again.
You made the claim that you can give a map on a square grid which produces exponential growth that will take billions of years to complete.
I laughed in your face and told you to do it.
You failed.
Show me one such grid and I'll solve it after work. Hell, show me three.
You don't know what you're talking about, and you made multiple claims of ability which, when challenged, you are backing away from.
Randomized depth first search is not my algorithm, and there are no clay prizes it satisfies. The Turing award would never be handed out for an algorithm which was well understood more than two hundred years before Turing was born.
Go on. Show me that billion year grid, since you're so certain you can produce it easily, and held that up as proof of your position.
Holding up an unrelated thing and waiting for the chance to say "it's not unrelated, you just don't get it" is not actually a case of your having shown that billion year grid you claimed you could make so easily.
For all your talk, you still have no idea what you're talking about, and you can't produce the things you claim you can.
Not A Real Mathematician (tm).