Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

15
votes
5answers
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 ...
20
votes
11answers
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 ...
7
votes
0answers
264 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. ...
7
votes
0answers
220 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
8answers
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 ...
24
votes
10answers
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 ...
25
votes
1answer
393 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! ...
12
votes
1answer
425 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 ...
20
votes
11answers
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 ...
29
votes
48answers
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 ...
18
votes
5answers
966 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. ...
18
votes
3answers
427 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 ...
17
votes
12answers
918 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 ...
8
votes
2answers
833 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 ...
14
votes
4answers
513 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 ...
15
votes
4answers
390 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 ...
16
votes
6answers
625 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 ...
20
votes
5answers
769 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 ...
22
votes
2answers
696 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 ...
1
vote
0answers
212 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 ...
9
votes
1answer
260 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 ...
12
votes
2answers
678 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 ...
13
votes
1answer
321 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 ...
5
votes
4answers
393 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 ...
8
votes
1answer
483 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 ...
10
votes
4answers
347 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 ...
43
votes
14answers
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 ...
14
votes
2answers
664 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 ...
9
votes
21answers
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 ...
33
votes
18answers
5k views

A Numpad's Knight Numbers

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 ...
19
votes
1answer
672 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 ...
2
votes
1answer
224 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 ...
9
votes
1answer
137 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 ...
8
votes
1answer
255 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 ...
28
votes
28answers
4k 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 ...
15
votes
2answers
317 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 ...
25
votes
5answers
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 ...
19
votes
5answers
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 ...
19
votes
5answers
625 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 ...
57
votes
72answers
8k 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. ...
16
votes
14answers
561 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 ...
21
votes
2answers
960 views

N-queen-and-equine quine

There is a variant of the well-known N-queens problem which involves queens and knights and is said to be "considerably more difficult" 1. The problem statement is as follows: You must place an ...
8
votes
2answers
217 views

The Black Pawn's Revenge

Objective The black pawn wants revenge. Plot out its last attack. Rules The black pawn (L) starts at the top row and moves downwards to the bottom row. Maximise ...
6
votes
1answer
383 views

The Attack of the Knights

Objective You have two knights on a standard chessboard labelled 1-8 and A-H, one knight is located at 1C and the other at 2G. You have to write a program in the language of your choosing that ...
17
votes
8answers
1k views

Capture on the Pawn Chessboard

You should write a program or function which receives a string representing a chessboard with only pawns as input and outputs or returns whether any capture is possible on the board. Input is in a ...
11
votes
3answers
2k views

ASCII Art Chessboard

In this challenge, you are to draw the chessboard below, and allow for moves to be made. 1. Drawing Each white square has 5x9 spaces. Each black square has 5x9 colons. The board is surrounded by a ...
14
votes
1answer
549 views

The lost pawn problem

The lost pawn problem After the chess game ended, a surviving pawn was left behind enemy lines. let's help him find the shortest way back home. The original problem describes a nXn "chess" board, ...
10
votes
4answers
547 views

Too many pawns on a chess board

Given an integer 2n, find the number of possible ways in which 2n^2 black pawns and 2n^2 white pawns can be arranged on a 2n by 2n chess board such that no pawn attack another. A black pawn can ...
14
votes
2answers
621 views

Explosions on a chessboard

Atomic chess is a (very fun) variant of chess in which every capture causes an "explosion," destroying the captured piece, the piece doing the capturing, and all non-pawns in a 1-square radius. The ...
3
votes
0answers
454 views

Stone Maze Chess solver [closed]

Background: Every war eventually comes to an end, but the end is never absolute. The Stone Maze Chess scenario takes place after a game of chess is finished. The enemy King is dead and the pieces is ...