Questions tagged [chess]
Chess is a strategic game played with two players on a checkered grid. This tag is for challenges related to chess or any variation on chess.
123
questions
16
votes
9
answers
585
views
Minimal number of jumps to reach a square
A Knight in chess moves two squares vertically and one square horizontally, or two squares horizontally and one square vertically (with both forming the shape of a capital L)
Given a Knight current ...
10
votes
5
answers
1k
views
Decode Chess Move
As the title says, given a valid chess move in algebraic notation, produce the string describing the move.
Example:
...
19
votes
14
answers
2k
views
Rook Polynomials
In combinatorics, the rook polynomial \$R_{m,n}(x)\$ of a \$m \times n\$ chessboard is the generating function for the numbers of arrangements of non-attacking rooks. To be precise:
$$R_{m,n}(x) = \...
6
votes
0
answers
310
views
Crazyhouse chess KoTH
What is Crazyhouse Chess?
Crazyhouse Chess is a chess variant that is basically normal chess except you can place a piece you previously captured back on the board instead of a regular turn.
Bot ...
24
votes
16
answers
4k
views
Is it a plausible chess move?
Not a duplicate of the valid move challenge because that asks for specific pieces.
Backstory
The other night I was doing a little trolling with ChatGPT and chess. I was trying to get it to call me out ...
8
votes
4
answers
354
views
Simultaneously solve N-queens and no-3-in-line
An intriguing MathsSE question asked if there were large N-queens solutions where no three queens lie on a line. That question's body included the unique 4×4 solution up to symmetries
...
9
votes
3
answers
350
views
Knook to Mate... With Portals!
Alternatively: Now you're checking with portals!
Inspired this challenge
I am somewhat of a self-declared Chess Anarchist. That means that when I play chess, en passant is forced (else the brick gets ...
24
votes
18
answers
3k
views
Knight to fork!
In chess, fork means to target two pieces with just one piece, and one of the best pieces for forking is the knight.
In this challenge, you will be given three coordinates in ...
6
votes
2
answers
348
views
Is this position a pure mirror mate?
Task
A pure mirror checkmate is a checkmate position, where the mated king is surrounded by 8 empty squares which are attacked or guarded by the winning side exactly once. You will be given a valid ...
12
votes
0
answers
437
views
Is it a legal atomic chess move?
Background and Rules
There is a variant of chess called atomic chess, which follows essentially the same rules as normal chess, except that pieces explodes other pieces around them when captured. In ...
10
votes
3
answers
335
views
Parlett's movement notation
Some chess variants use interesting non-standard pieces. In order to concisely describe new pieces or to describe pieces without requiring everyone to memorize a bunch of non-standard names some new ...
21
votes
9
answers
1k
views
A pieceful standoff
This challenge requires a small amount of knowledge about chess. A description of the details required can be found at the bottom if you are not familiar with chess or want a refresher.
For a certain ...
26
votes
14
answers
3k
views
Print every Fool's Mate
In chess, the Fool's Mate is the fastest possible way to reach checkmate. It is reached with Black's second move. In chess notation, one possible sequence of moves that achieves Fool's Mate is ...
9
votes
3
answers
1k
views
The smallest number of steps for a chess piece to reach a position
I have previously posted a challenge, smallest number of steps for a knight in chess.
Now I would like to go a step further by adding the possibility to choose your piece.
If you place a piece on any ...
32
votes
31
answers
5k
views
A challenge for rookies
Print or return the following string:
...
23
votes
15
answers
3k
views
smallest number of steps for a knight in chess
If you place a knight on any square of a chessboard, what is the smallest amount of steps to reach every position?
Rules
It is an 8 by 8 board.
The knight starts at an arbitrary position, taken as ...
24
votes
8
answers
2k
views
Seeing the queen's lasers
In chess, the queen piece can move arbitrarily far in each cardinal and intercardinal direction. What does this mean? Well, I'll show you with an ASCII drawing:
...
12
votes
11
answers
2k
views
Convert Descriptive Notation to Algebraic Notation
Introduction
Many old chess books use descriptive notation to notate squares on a chessboard, naming the file (column) of the square based on the starting piece positions of White or Black, depending ...
23
votes
35
answers
4k
views
Generate All 8 Knight's Moves
Introduction
In chess, Knights can move two squares in one direction, and then one square in an orthogonal direction. On an x/y plane, these can be thought of as being a relative change of coordinates,...
11
votes
7
answers
735
views
Knights Jam | Chess
The knight is a chess piece that, when placed on the o-marked square, can move to any of the x-marked squares (as long as they ...
18
votes
11
answers
1k
views
Identify a "reverse checkers" position
Task
A reverse checkers position is a chess position where every piece for one player is on one colour and every piece for the other player is on the other colour. Your task is to find if the given (...
25
votes
31
answers
3k
views
Generate the Chess Numbers™
I was browsing Stack Overflow when I saw this post in Puzzling in the hot network questions and decided to make a challenge out of it (all credit goes to the creator of the challenge).
Overview
A ...
24
votes
12
answers
2k
views
Greedy queens sequence
Challenge
Implement the "greedy queens" sequence (OEIS: A065188).
Details
Taken from the OEIS page.
This permutation [of natural numbers] is produced by a simple greedy algorithm: starting ...
9
votes
0
answers
372
views
Chess Squad March
Find the moves that bring a chess squad to a given destination.
You control a chess squad consisting of a king and several other pieces, on a larger chess board. Your army is placed so that no piece ...
23
votes
13
answers
1k
views
Generalised multi-dimensional chess knight's moves
Multi-dimensional chess is an extension of normal chess that is played on an 8x8x8x8... "board".
In normal 2D chess, a knight's move is a movement by a vector of \$ \begin{bmatrix} \pm 2 \\ \...
13
votes
8
answers
1k
views
Is this FEN board a Fischer random chess starting board?
Introduction
Fischer random chess, also known as Chess960 for the 960 valid starting boards, is a variant of chess where each player's pieces are randomly shuffled at the start. As a reminder, each ...
18
votes
9
answers
1k
views
Dimensional Chess positions
Task
Any one of these two:
Determine if a given position (an ordered non-empty collection of integers in the range ‒8 to 8, or ‒7 to 7 if you want) is a valid Dimensional Chess position.
List all the ...
24
votes
4
answers
2k
views
Is it a chess cycle?
Inspired by a discussion from the Esolangs.org unofficial Discord Server.
Instructions
A chess cycle is an arrangement of a chess board where each piece must attack one other piece, and only one other ...
9
votes
5
answers
424
views
Print the Najdorf Sicilian
The Najdorf Variation of the Sicilian Defence is an opening often played at the highest level of chess. It is named after GM Miguel Najdorf and is known for being extremely sharp and theory heavy.
...
9
votes
1
answer
343
views
Win a KQ vs K endgame
Win a K vs KQ endgame
Summary
The goal of this challenge is to create a program or function which will win a Chess game with a King and Queen against a lone King. The user will specify three squares, ...
26
votes
2
answers
641
views
Chess murder mystery
You know how many and which kinds of chess pieces were murdered. Can you come up with any possibility for who killed whom and how?
Background
During the course of a game of chess, there are between 2 ...
33
votes
12
answers
3k
views
The Knight's Dialer
Imagine you place a knight chess piece on a phone dial pad. This chess piece moves from keys to keys in an uppercase "L" shape: two steps horizontally followed by one vertically, or one step ...
11
votes
4
answers
396
views
Holey Knight's Tour
Given a rectangular board of cells with some number of holes in it, determine whether it is possible to complete a "holey knight's tour" (That is, a path that visits every non-hole cell exactly once ...
13
votes
6
answers
978
views
Counting Queen's paths on a rectangular chessboard
Task
Given two positive integers \$m,n\$, imagine a chessboard of size \$m \times n\$. A chess queen is on the upper-left corner. In how many ways can it reach the lower-right corner, by moving only ...
116
votes
10
answers
11k
views
Totally Blind Chess
In this challenge, you play chess without seeing any of your opponent's pieces or moves. Or your own pieces. Or whether your own moves succeeded. You send only a stream of moves, with no feedback. If ...
34
votes
28
answers
3k
views
Count rook moves 1D
Given a position with a row of rooks and/or empty spaces, output how many different rook moves are possible. A rook can move left or right to an empty space, but not to one that requires passing over ...
14
votes
3
answers
1k
views
Is it checkmate?
Wholly surprised this hasn't been posted already, given the large number of chess puzzles on the site. While I thought of this myself, credit to Anush for posting it to the sandbox back in March. But ...
13
votes
8
answers
2k
views
Is this draw by repetition?
Problem:
In chess, there is a somewhat well known rule about draw by repetition. If the same position is repeated 3 times (or more) then the player intending to make the move which will cause the this ...
2
votes
1
answer
197
views
Find all diagonal counts in only one direction [closed]
If I need to get the number of diagonal squares in all directions:
I do the following formula 2 N − 2 − |x − y| − |x + y − N − 1|
The above example has 13 and ...
17
votes
6
answers
741
views
Passwords Strong Against Bishops
Not to be confused with Password Bishop Goodness!
Given a string, answer (truthy/falsy or two consistent values) if it constitutes a password which is strong against bishops.
A password is strong ...
48
votes
8
answers
3k
views
N-movers: How much of the infinite board can I reach?
Single moves
The board is an infinite 2 dimensional square grid, like a limitless chess board. A piece with value N (an N-mover) can move to any square that is a distance of exactly the square root ...
24
votes
3
answers
2k
views
The Path Of The Wildebeest
Golf a program or function which gives the \$n^{\text{th}}\$ location of the wildebeest who starts at square \$1\$ on an infinite chessboard which is numbered in an anti-clockwise square spiral, where ...
17
votes
5
answers
1k
views
How many moves?
Given two different positions on a chess board and the type of piece, output the minimum number of moves it will take for that piece to go from one position to another.
Rules
The given piece can be ...
21
votes
11
answers
2k
views
A knight's graph on an N-by-N board
In chess, a knight can only move to the positions marked with X relative to its current position, marked with ♞:
A Knight's Graph is a graph that represents all legal moves of the knight chess piece ...
11
votes
1
answer
504
views
Recording xiangqi moves
The game of xiangqi, also known as Chinese chess, is a chess-like game popular in China, Vietnam, Taiwan, and other East Asian countries. The colours of the two sides in xiangqi are red and black. ...
9
votes
0
answers
463
views
The N Queens Problem, but with Fairy Chess Pieces
Fairy Chess is a sort of generalized chess that allows unconventional pieces. The eight queens puzzle is a classic problem where you have to put 8 queens on a chess board such that no two queens ...
26
votes
8
answers
2k
views
Mutually Attacking Queens
Let an 8x8 chessboard be represented by any two distinct values, with one value being an empty square and the other being a queen. In the following examples, I use 0s as the empty squares and 1s as ...
26
votes
10
answers
2k
views
Knight Distance
In Chess, a Knight on grid \$(x, y)\$ may move to \$(x-2, y-1)\$, \$(x-2, y+1)\$, \$(x-1, y-2)\$, \$(x-1, y+2)\$, \$(x+1, y-2)\$, \$(x+1, y+2)\$, \$(x+2, y-1)\$ or \$(x+2, y+1)\$ in one step. Imagine ...
27
votes
1
answer
746
views
Three-Dimensional Chess
In order to defend someone’s baffling decision, people often say that that person is going over everyone’s heads and playing “3-dimensional chess”. Now it’s your chance to play 3-dimensional chess!
...
22
votes
4
answers
3k
views
Is it a valid chess move?
Alternate name: ChessMoveQ
Given a list of up to 32 elements, each consisting of 4 elements, and a second list with 4 elements, determine whether the move detailed ...