Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Thursday Code Puzzler: N-Queens Revisited

DZone's Guide to

Thursday Code Puzzler: N-Queens Revisited

· Java Zone ·
Free Resource

Download Microservices for Java Developers: A hands-on introduction to frameworks and containers. Brought to you in partnership with Red Hat.

It's code puzzler day, but today we'll do something a little different. I was looking back at some of the previous puzzlers - we've been through quite a few since we started the series in April 2012. I thought it might be fun to review the first puzzler  : the N-Queens problem. 

In case you're unfamiliar with the problem, here's the summary we posted: 

One of the classic programming challenges. What you need to do is place 8 queens on an 8x8 chess board in a way that no two queens attack each other. For those who don't play chess, this means that no two queens can be on the same row, column or diagonal.  Sounds simple? Go! 

If you check the  comments , you'll see there are a couple of solutions in there. However, I know we have gained some regular visitors to our weekly puzzler spot since then, so I'd like to invite everyone to take another shot at it. Is there any improvements that can be made to the solutions that were submitted? Can you write a solution that will get the problem solved in a lower execution time? 



Download Building Reactive Microservices in Java: Asynchronous and Event-Based Application Design. Brought to you in partnership with Red Hat

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}