Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

71%
+3 −0
Challenges 8 coexisting queens

This is a fixed output challenge. Output a textual representation of a chessboard hosting 8 queens, none of which are attacking each other. There are 92 ways of arranging them, 12 if rotations and...

5 answers  ·  posted 2y ago by trichoplax‭  ·  last activity 2y ago by m90‭

#1: Initial revision by user avatar trichoplax‭ · 2022-09-29T12:13:45Z (about 2 years ago)
8 coexisting queens
This is a fixed output challenge. Output a textual representation of a chessboard hosting 8 queens, none of which are attacking each other.

There are 92 ways of arranging them, 12 if rotations and reflections are discounted. You may choose any 1 of these arrangements.

You are not required to calculate or search for a valid arrangement. Hardcoding your choice of arrangement is one possible valid solution.

## Input
- There is no input for this challenge

## Output
- 8 newline separated lines of 8 characters, with an optional trailing newline
- Each character is either a queen or an empty square. You may choose any two distinct characters to represent a queen and an empty square
- No more than 1 queen appears in each row, column, and diagonal
- There are 8 queens in total
- Your output must be the same each time (your code must have deterministic output, even if it uses a probabilistic approach internally)

## Examples
The examples show a queen as `Q` and an empty square as `#`. There are 12 examples, one for each of the fundamental solutions (before rotation and reflection). Any combination of rotating and reflecting one of these examples is also a valid solution.

```text
###Q####
######Q#
##Q#####
#######Q
#Q######
####Q###
Q#######
#####Q##

####Q###
#Q######
###Q####
######Q#
##Q#####
#######Q
#####Q##
Q#######

###Q####
#Q######
######Q#
##Q#####
#####Q##
#######Q
####Q###
Q#######

###Q####
#####Q##
#######Q
##Q#####
Q#######
######Q#
####Q###
#Q######

##Q#####
#####Q##
#######Q
Q#######
###Q####
######Q#
####Q###
#Q######

####Q###
##Q#####
#######Q
###Q####
######Q#
Q#######
#####Q##
#Q######

####Q###
######Q#
###Q####
Q#######
##Q#####
#######Q
#####Q##
#Q######

###Q####
Q#######
####Q###
#######Q
#####Q##
##Q#####
######Q#
#Q######

##Q#####
#####Q##
###Q####
Q#######
#######Q
####Q###
######Q#
#Q######

#####Q##
#Q######
######Q#
Q#######
###Q####
#######Q
####Q###
##Q#####

###Q####
######Q#
Q#######
#######Q
####Q###
#Q######
#####Q##
##Q#####

#####Q##
###Q####
######Q#
Q#######
#######Q
#Q######
####Q###
##Q#####
```

The 12 fundamental solutions were taken from the [Wikipedia page for the 8 queens puzzle](https://en.wikipedia.org/wiki/Eight_queens_puzzle#Constructing_and_counting_solutions_when_n_=_8) which also provides them as images:

[![The 12 fundamental solutions to the 8 queens puzzle](https://codegolf.codidact.com/uploads/WA6gMm476tdsgfbzPQHTPdUF)](https://en.wikipedia.org/wiki/Eight_queens_puzzle#Constructing_and_counting_solutions_when_n_=_8 "View the images on Wikipedia")

## Scoring
Despite there being 92 valid outputs, this is a standard code golf challenge. Your score is the number of bytes in your code.


> Explanations in answers are optional, but I'm more likely to upvote answers that have one.