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 »
Sandbox

8 coexisting queens [FINALIZED]

+0
−0

Now posted: 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.

###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 which also provides them as images:

The 12 fundamental solutions to the 8 queens puzzle

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.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

1 comment thread

Include the Layouts (2 comments)