# 8 queen problem with a twist

• (2 Pages)
• 1
• 2

## 16 Replies - 1581 Views - Last Post: 04 August 2014 - 05:28 AMRate Topic: 3 Votes //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=351323&amp;s=29e9de3d8e12f581449b92087254b70a&md5check=' + ipb.vars['secure_hash'], cur_rating: 2, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #16 Darraptor

Reputation: 0
• Posts: 66
• Joined: 11-May 14

## Re: 8 queen problem with a twist

Posted 03 August 2014 - 11:37 PM

Skydiver, on 02 August 2014 - 06:25 AM, said:

If you are not being graded on algorithm design and efficiency, you could go for the brute force algorithm. In pseudo code:
```for each row
for each column
if row,col is occupied
continue
place queen at row,col
check if valid
if invalid
undo placing queen at row, col

```

If I wasn't assigning a certain amount of queens a position on the board I wouldnt have too much trouble but Im really lost right now could you help. Sorry if I sound annyoing but ive been doing this for hours and i really can't get it

### #17 Skydiver

• Code herder

Reputation: 6164
• Posts: 21,251
• Joined: 05-May 12

## Re: 8 queen problem with a twist

Posted 04 August 2014 - 05:28 AM

Show us your code for how you solve the problem when the board is completely blank. Notice, that the way that works is by attempting to place the queen and then seeing if it is valid, and if so it continues on, otherwise it undoes that placement.

How is the computer placing some of the queens any different from the human first placing some of the queens?