8 coexisting queens [FINALIZED]
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:
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.
1 comment thread