# 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.

85 questions
Filter by
Sorted by
Tagged with
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 ...
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 ...
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 ...
180 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 ...
591 views

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 ...
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 ...
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 ...
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 ...
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 ...
290 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. ...
286 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 ...
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 ...
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), (x+2, y+1) in one step. Imagine an infinite chessboard with only a ...
448 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! ...
631 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 ...
3k views

### Where can the knight be in N moves?

This is Hole-3 from The Autumn Tournament of APL CodeGolf. I am the original author of the problem there, and thus allowed to re-post it here. Given: a number of turns (please state if no movements ...
9k views

### How many Wazirs can be placed on an N×N Chessboard?

Suppose a new fairy chess piece named the Wazir is introduced to chess. Wazirs can move from a position (x, y) to:  (x+1, y)  (x, y+1)  (x-1, y)  (x, y-1) That is, they move orthogonally like the ...
983 views

### Is this a losing square?

There is a game called Get Home that is played on the a chess board. In this game there is a single piece that is moved by both players in turns. There are some rules to how the piece can be moved. ...
470 views

### When Fibonacci meets the Queens

(inspired by Helka's response to my random pairing of "chess" and "Fibonacci" tags in chat) Fibonacci The Fibonacci numbers are one of the more well-known sequences in mathematics, where each number ...
1k views

### N-Queens Puzzle

(Despite 60+ questions tagged chess, we don't have a simple n-queens challenge.) In chess, the N-Queens Puzzle is described as follows: Given an n x n chessboard ...
938 views

### Smallest chess game compression

Inspiration: Heavily inspired by Smallest chess board compression I decided to make a similar but distinctly different competition. tl;dr Take the file Chess_Games.txt and compress it as much as ...
541 views

### Peaceable coexisting armies

In the game of chess, there is piece called the queen that may attack any other piece that is on the same row, column or diagonal. In chess there are typically two sides, black and white, with each ...
427 views

### Knight-fill a grid

A knight fill is a flood fill using the connectivity of the knight chess piece. Specifically: 1 1 1 1 0 1 1 1 1 (0 is the initial point, 1s show the ...
647 views

### Working on my Knight moves

Hexagonal chess describes a family of chess variants played on a board where the cells are hexagons instead of the traditional squares. There are many such variants; in this challenge we'll be ...
792 views

### Chess Analysis with Limited Information

In this challenge, you are given a limited amount of information about a particular game of chess, and you need to predict who won the game. You are given two sets of data: Piece counts (What ...
746 views

### Escape a chessboard

You find yourself on a chessboard, as one does. You can see the exit but it is awfully far away and you would rather not walk all the way. Luckily some locals have offered you a ride. A Knight, a ...
272 views

### Generalization of Eight Queen Puzzle [closed]

Here's one generalized version of the famous Eight Queen's Puzzle: Given an n × n chess board, and an integer ...
274 views

### Where can the cannon go?

Introduction 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 ...
769 views

### Solve a Solitaire Chess Puzzle

Recently, I was introduced to a puzzle game known as Solitaire Chess. I'll summarize the rules here: The board is a 4x4 checkerboard. All pieces are the same color (no teams) and all pieces can ...
356 views

### Chess conversion

There's quite a lot of work that's been done in the world of chess. For example, there is a standardized file format, .pgn, that describes a chess game, including ...
446 views

### Help Sam understand chess

For this challenge, you will be writing a program or function which outputs (or prints) (in a reasonable format, i.e single string or an array of lines) a chess board indicate all the possible moves ...
640 views

### Convert Algebraic notation to Descriptive notation

Mr Short likes to play chess. Mr Short is also a very traditional man. Hence, Mr Short is disturbed by the recent trend of using Algebraic notation in modern chess, and he would rather use Descriptive ...
362 views

### A queen's walk across a spiral

In a far-off kingdom, a chess queen takes a daily walk across a spiral path, numbered from 1 to n, not caring to follow the spiral itself, but simply making queen's ...
5k views

### Knight on the Rim is Grim

Introduction Aron Nimzowitsch was a leading chess master and a influential chess writer. In his book 'My System', the first chapter deals about the importance of the center and why you should ...
688 views

### Chessboard maze

Chess pieces (kings, queens, rooks, bishops, and knights) and pawns are on a board, but not on the a1 or h8 square. Your task is to travel from the empty a1 to the empty h8 squares, passing through ...
2k views

### Convert a Forsyth-Edwards Notation string to ASCII art

In chess, Forsyth-Edwards Notation, more commonly called "FEN", is a textual way of transcribing boards. It describes each of the board's eight rows (called "ranks" in chess) from top to bottom from ...
5k views

For the non-zero digits on a standard numpad 789 456 123 consider placing a chess knight at any digit and moving it around with any number of normal L-shaped ...
683 views

### Seeking Leapers

I recently got a really weird irregular chess board. It's squares are all over the place and not even all connected. At least they're still laid out on a regular grid. I want to adapt the chess rules ...
231 views

### Convert a pawn promotion from algebraic to ICCF numeric notation

Input A single string, which contains no whitespace, as a command-line argument. Output If the string is not a valid algebraic notation pawn promotion, produce no output and exit. If the string is ...
154 views

### Diagram of a leaper [duplicate]

Given an input of a pair of nonnegative integers describing a leaper in chess, output a diagram of the squares to which the leaper can move. From Wikipedia's description: An (m,n)-leaper is a ...
264 views

### The knight's next tour

We've all heard of the Knight's Tour puzzle: find a route for a knight that passes through all the squares on a chess board. But let's be honest, it's a little bit boring. So, let's give the knight a ...
5k views

### Output all the white or black squares of a chessboard

Introduction This is how a chessboard looks like. You can see that a1 is a dark square. However, b1 is a light square. The ...
329 views

### Chess-olition Derby

What could be more polar opposites than chess and demolition derby. You would think that no one who enjoys one would enjoy the other... until today. Rules The starting position is a standard chess ...
2k views

### Can the king catch the pawn?

Given an input of four integers x1, y1, x2, and y2, output whether a white king in chess (with coordinates (x1, y1)) could catch a black pawn (with coordinates (x2, y2)) and capture it if the pawn ...
1k views

### Play Antichess!

https://en.wikipedia.org/wiki/Losing_chess This is basically Chess Tournament, but for antichess ;) Antichess is one of the many chess variants that have been invented. The goal is to lose all your ...
714 views

### 8-bit Chess Pixel Counting

Goal You're playing a computerised chess game. The display is in black and white only and the pixels are chunky. White pixels use a lot power compared to black pixels and you're concerned about ...
9k views

### Determine the color of a chess square

Your challenge is to write a program that outputs the color of a given square from the chessboard. This is how a chessboard looks: You can see that the square a1 is dark, and h1 is a light square. ...
671 views

### Evaluating the score based from a chess FEN string

Challenge Forsyth–Edwards Notation (FEN) is a standard notation for describing a particular board position of a chess game. Your challenge is to evaluate the score using the FEN string. This is an ...