Wednesday, June 09, 2004

Re: N-queens solution

Revo of course the thing will work!!! I was really stupid, I should have given your'll this solution rather than the duplicate one. Remember I had said, I had written a program before also on 8-queens using brute search rather than "back-tracking", well that incorporated this idea.

This was at the back of my mind, but just forgot to use it for optimization! I'm sorry, I can get pretty dumb like this at times!! Thanks Revo!!

My aim for this thing was brushing up with C++, hence it's a little more complex than it should be. But I had a lot of fun with it.

I did the whole duplicate thing because I wanted to see what happened if I started say for an initial position on (0,0), I appended the nth-level queen to it. I wanted to see if the path taken was any different. But the nature of the problem is still such that, even if I append an nth-level queen all it gives me is a duplicate of the original solution! This is really a cool problem!

So I wanted to make a multi-level search and see what I found rather than just making a single-level search. For me the most interesting thing was the tree structure that was getting created.

You can find the optimized source here: Windows & Linux

Dinesh.

No comments: