2022 Developer Survey is open! Take survey.

Hot answers tagged

61 votes

Determine the color of a chess square

Python 2, 41 38 bytes print'ldiagrhkt'[int(input(),35)%2::2] 3 bytes thanks to Mego for string interlacing Takes input like ...
user avatar
  • 41.3k
48 votes
Accepted

Determine the color of a chess square

GS2, 17 15 bytes de♦dark•light♠5 The source code uses the CP437 encoding. Try it online! Verification ...
user avatar
  • 206k
33 votes

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

Whitespace, 45 bytes Try it online! By the way, here ...
user avatar
  • 65.5k
26 votes

Determine the color of a chess square

Hexagony, 34 32 bytes ,},";h;g;;d/;k;-'2{=%<i;\@;trl;a Unfolded and with annotated execution paths: Diagram generated with Timwi's amazing HexagonyColorer. ...
user avatar
25 votes

Knight on the Rim is Grim

Python 2, 35 bytes lambda x,y:50/(8+x*x/7-x+y*y/7-y)-4 Try it online! Python 2, 39 bytes ...
user avatar
  • 137k
25 votes

Totally Blind Chess

Just Everything Generates a list of every possibly legal move, shuffles it, then cycles through it repeatedly. Since there are only 1792 possibly legal moves, this will never forfeit due to the 2000-...
user avatar
  • 1,196
21 votes
Accepted

Smallest chess program

C, 650 600 ...
user avatar
21 votes

The Path Of The Wildebeest

JavaScript (Node.js),  191 ... 166  164 bytes Saved 2 bytes thanks to @grimy. Returns the \$N\$th term. ...
user avatar
  • 166k
21 votes

Totally Blind Chess

Zombie March Slowly walks all its pieces forward across the board, in a random order (but favoring pawns). The first 5 moves sent specifically counter the scholar's mate. ...
user avatar
  • 1,196
20 votes

Determine the color of a chess square

CJam, 18 bytes r:-)"lightdark"5/= Online demo Dissection ...
user avatar
  • 42.8k
20 votes

The Knight's Dialer

JavaScript (ES6),  62 61  60 bytes My Python port, ported back to JS. :-p f=(n,k,o=k%2)=>n--?k-5&&(2-o)*f(n,!k*3-~o)+(k&5&&f(n,o*4)):1 Try ...
user avatar
  • 166k
19 votes

N-movers: How much of the infinite board can I reach?

JavaScript (Node.js), 144 138 125 74 73 70 bytes f=(x,n=2,c=0)=>x%n?x-!c?f(x,n+1)/(n%4>2?n/=~c&1:n%4)**c:1:f(x/n,n,c+1) Try it online! -4 byte thanks @...
user avatar
18 votes

Can the king catch the pawn?

Python 2, 53 40 lambda x,y,p,q:y-2<q>=abs(x-p)+q/7+y/8*5 The king has coordinates (x, y) and the pawn ...
user avatar
  • 18.9k
18 votes

A Numpad's Knight Numbers

Python 2, 52 bytes f=lambda n:n<6or`n%100`in'18349276167294381'*f(n/10) Checks that any two consecutive digits are in the string ...
user avatar
  • 137k
17 votes

Knight on the Rim is Grim

MATL, 17 14 13 12 bytes Thanks to @Neil for 1 byte off! 8:HZ^ZP5X^=s Input is 1-based. Try it online! Explanation This computes the Euclidean distance from the ...
user avatar
  • 99.3k
16 votes

Determine the color of a chess square

sed, 37 s/[1357aceg]//g /^.$/{clight q} cdark Explanation s/[1357aceg]//g removes all odd-indexed coordinates. The ...
user avatar
16 votes
Accepted

A Numpad's Knight Numbers

Jelly, 19 15 14 bytes Doȷ’d3ạ2\P€=2P Try it online! or verify all test cases. How it works ...
user avatar
  • 206k
16 votes

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

Oasis, 3 bytes k>v Try it online! square - increment - integer halve
user avatar
  • 48.2k
16 votes

Totally Blind Chess

Scholar ...
user avatar
  • 21.8k
15 votes
Accepted

Output all the white or black squares of a chessboard

Pyth, 22 21 bytes -1 byte by @Sp3000 fn%Chz3%sCMT2sM*<G8S8 Under the function %Chz3, dark...
user avatar
  • 21.2k
15 votes

Convert a Forsyth-Edwards Notation string to ASCII art

Retina, 13 bytes \d $* / ¶ | Try it online! Explanation The first part (note the trailing space): \d $* is to convert ...
user avatar
  • 28.4k
15 votes

Knight on the Rim is Grim

Mathematica 63 43 bytes With 20 bytes saved thanks to suggestions by Martin Ender! EdgeCount[8~KnightTourGraph~8,#+1+8#2/<->_]& The above finds the ...
user avatar
  • 25.1k
15 votes

Totally Blind Chess

Blunt Instrument v2 There was a severe bug in the previous implementation that caused my bot to occasionally move pieces away from the enemy king. Given that the king is the most important piece, ...
user avatar
  • 1,843
15 votes

Identify a "reverse checkers" position

Python, 34 bytes lambda p:{*p[::2]}<{*p}>{*p[1::2]} Attempt This Online! Accepts a single string. Works for any distinct 4 characters for empty,black,white,newline. How? Uses the fact that ...
user avatar
  • 5,820
14 votes

Mutually Attacking Queens

Python 2, 105 bytes lambda b:sum(b[i+d::d][:(8,7-i%8,i%8)[d%8%5]].find('1')*int(c)>0for i,c in enumerate(b)for d in[1,7,8,9]) Try it online! Explanation We ...
user avatar
  • 65.5k
13 votes

Smallest chess program

Python 3, 1166 1071 993 bytes I only realized I needed to stop kings from moving into check after I had otherwise finished, but here's my submission anyways ...
user avatar
13 votes

Capture on the Pawn Chessboard

Retina, 33 29 bytes T`d`w )`\d $0. _ p.{7}(..)?P To run the code from a single file, use the -s flag. Should be easily ...
user avatar
13 votes

Determine the color of a chess square

Pyth, 18 bytes @c2"lightdark"iz35 Interpret the input as a base 35 number, chop lightdark in half, print.
user avatar
  • 41.3k
13 votes

Output all the white or black squares of a chessboard

Bash + GNU Utilities, 74 printf %s\\n {a..h}{1..9}|sed -n "`sed '/[db]/a1~2p /t/a2~2p c/9/d'<<<$1`" ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible