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 :)
20
Upvotes
View all comments
Show parent comment
1
u/StoneCypher Sep 08 '11
I love how you run two different things I said together, to make it look like I said something different than what I said.
No, it isn't. This is simple depth-first search. There is no sampling process other than metaphor, and there is no "early stopping," only search.
This is not an "optimization." This is a rudimentary description of unoptimized depth first search.
Please stop arguing now. This can very easily be refined from where it is; calling it optimized and referring to it by radically the wrong names just makes you look like a novice.
Pretending that something is optimized brute force merely because it doesn't do any brute forcing is stupid.
Since you don't appear to know much about computer science, I'll remind you that iteration is ordered first to last, which is what makes it different than random or unordered access. The first to last order of a grid is quite clear, and reflection and rotation don't make any difference.
So unless you're pretending that scatter or spiral or something stupid are legitimate interpretations of iteration, I'd wager that you're just desperately scrambling to invent technicalities to cover for the rudimentary error you made.
No. You can't. You're just making up big-sounding numbers. The worst possible ordering will take less than five minutes on a gameboy advance.
You don't actually understand this problem as deeply as you seem to imagine that you do.
No. You can't.
I invite you to prove your own claim now. I'm getting tired of amateur hour at the big-sounding claims podium.
There isn't enough hard drive space on earth to make a map I can't four-color in a matter of hours; the only way to make this slow is to make things so absurdly large that you start hitting machine limits, which is on the order of mapping every city block on earth as a discrete polygon.
You don't know what you're talking about.