Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

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.

Filter by
Sorted by
Tagged with
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 ...
10
votes
4answers
579 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 ...
10
votes
4answers
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 ...
10
votes
1answer
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 ...
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 ...
9
votes
4answers
2k views

N-Queens problem [closed]

In chess, a queen can move as far as as the board extends horizontally, vertically, or diagonally. Given a NxN sized chessboard, print out how many possible positions N queens can be placed on the ...
9
votes
1answer
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 ...
8
votes
2answers
942 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 ...
8
votes
1answer
674 views

The smallest Chess arbiter

Write a program, which, upon gazing at a chess table, can say whether there is a check or a checkmate. Input: a chess table in text form, the last line of the input being the first rank (the starting ...
8
votes
2answers
219 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 ...
8
votes
1answer
647 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 ...
8
votes
1answer
265 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 ...
8
votes
1answer
596 views

Tic-Tac-Toe and Chess, with fewest [distinct] characters

In this form of the game Tic-Tac-Chec, the goal is to move chess pieces to get four-in-a-row. Your goal here is to figure out if a position has a winning move. Rules The rules are similar, but not ...
7
votes
10answers
579 views

Chess960 position lookup

This is a follow-up to Chess960 position generator. In Chess960, there are 960 possible starting positions that can be enumerated from 0 to 959 (or, at your choice, from 1 to 960). The enumeration ...
7
votes
6answers
706 views

Neustadtl score

Write the shortest function that takes a two-dimensional square array representing the scores of a chess round, and outputs an array of the Neustadtl scores of the players. The two-dimensional array ...
7
votes
5answers
3k views

A simple Knight's problem

How many ways are there to place a black and a white knight on an N * M chessboard such that they do not attack each other? A knight can move two squares horizontally and one square vertically, or ...
7
votes
0answers
292 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
288 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 ...
6
votes
7answers
636 views

How many squares are guarded by chess queens?

Today marks the 15th anniversary of Garry Kasparov's defeat against Deep Blue. Speaking of chess... Input is a string that represents an 8x8 chess board containing only empty squares (...
6
votes
4answers
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 ...
6
votes
1answer
550 views

Build a working chessboard

The challenge Create a program that mimics a chessboard. The datails The chessboard must be surrounded by the labels of each row and column, being the columns labeled from 'a' to 'h' and the rows ...
6
votes
1answer
532 views

Set the chessboard

Objective Given an arbitrary chessboard as standard input (in which each piece is on a square), produce as standard output a list of moves needed to regularize, or set up, the chessboard. The moves ...
6
votes
1answer
389 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 ...
6
votes
0answers
976 views

Simple chess bot

Inspired by this Implement simple chess bot (with console or GUI) that has following features: [Pseudo-]graphically showing the board; Accepting user moves and making their own moves; Playing by ...
5
votes
10answers
2k views

Eight Queens Obsfucation [closed]

You've probably heard of the classic Eight Queens Puzzle. For those of you who haven't it goes something like this: Position 8 queens on an 8×8 chessboard so that no two queens threaten each ...
4
votes
1answer
1k views

Determining the winner of a Chess game

Challenge Being someone who plays far too much chess in his spare time, I thought I'd set a code golf challenge inspired by the game of chess (with a software flavour), for those interested. The ...
4
votes
0answers
575 views

Chess Light Solver

Challenge Write a solver for the Chess Light puzzle game, in the smallest amount of code. The input will be a representation of a chessboard, how in yours is up to you. My examples below is textual, ...
3
votes
8answers
2k views

n-queens problem, displaying more than one solution available

as some of you may know, n-queens problem is a set of algorithm puzzle that given a 'n x n' where n is the board size of a (let's say) chessboard, and the main goal is for the n queens (where n is the ...
3
votes
1answer
931 views

Domination problem in chess

Given an mxm chess board, find a minimum number of pieces of the given kind and place them on a chess board in such a way that ...
3
votes
0answers
466 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 ...
2
votes
1answer
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 ...
2
votes
1answer
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 ...
2
votes
0answers
245 views

Write the shortest code that bring to a solution of “The old curious knight with a lazy horse” problem [duplicate]

The Story: Once upon a time there was a curious Knight that lived on a never used chessboard in the Realm, an antique store. He spent all his career over there and when it came the moment of the ...
1
vote
0answers
274 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 ...
-2
votes
7answers
1k views

Knight's tour on a rectangle

Given an a-by-b sized grid, and a chess knight, determine: A starting point and path the knight can take to visit every square in the grid or "NOT POSSIBLE", if not possible. Input: Two integers, <...