39 votes

A challenge for rookies

J, 29 27 24 23 bytes ' .*xR'{~*/~,0,.~1+=i.8 Try it online! My initial observation was that the output is essentially a row-wise function table of the 8x8 identity ...
Jonah's user avatar
  • 33.4k
33 votes

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

Whitespace, 45 bytes Try it online! By the way, here ...
Lynn's user avatar
  • 68.7k
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 ...
xnor's user avatar
  • 145k
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-...
Brilliand's user avatar
  • 1,226
22 votes

The Path Of The Wildebeest

JavaScript (Node.js),  191 ... 166  164 bytes Saved 2 bytes thanks to @grimy. Returns the \$N\$th term. ...
Arnauld's user avatar
  • 192k
22 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. ...
Brilliand's user avatar
  • 1,226
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 ...
Arnauld's user avatar
  • 192k
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 @...
Shieru Asakoto's user avatar
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 ...
xnor's user avatar
  • 145k
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 ...
Luis Mendo's user avatar
  • 104k
17 votes

Totally Blind Chess

Scholar ...
histocrat's user avatar
  • 22.2k
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 ...
Dennis's user avatar
  • 210k
16 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 ...
Downgoat's user avatar
  • 29k
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
Leaky Nun's user avatar
  • 49.7k
16 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 ...
loopy walt's user avatar
  • 16.7k
16 votes

Knight to fork!

Python 2, 129 bytes def f(a):x,p,y,q,z,r=map(ord,a);x-=z;y-=z;p-=r;q-=r;u=x*x+p*p;v=y*y+q*q;w=x*q-y*p<<1;return chr((u*q-v*p)/w+z)+chr((v*x-u*y)/w+r) Try it ...
tsh's user avatar
  • 34.7k
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...
lirtosiast's user avatar
  • 21.5k
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 ...
DavidC's user avatar
  • 25.3k
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, ...
ymbirtt's user avatar
  • 1,873
15 votes
Accepted

Totally Blind Chess

Pokey Opens with the knight-based variant of the Scholar's Mate (a 5-move checkmate). If this fails, it presses the attempt a little farther, with a sequence of moves that hardcounters Prickly. The ...
Brilliand's user avatar
  • 1,226
15 votes

Generate All 8 Knight's Moves

Wolfram Language (Mathematica), 25 bytes Solve[x^2y^2==4,Integers] Try it online! Outputs a list of {x -> x, y -> y}s.
att's user avatar
  • 20.4k
15 votes

Is it a plausible chess move?

Octave, 24 bytes @(a,b)imag((a-b)**4)<28i Try it online! Takes two complex numbers as inputs. How? Port of @xnor's python answer plus a trick or two by myself. ...
loopy walt's user avatar
  • 16.7k
15 votes

Is it a plausible chess move?

Python 2, 29 bytes lambda a,b:abs((a-b)**4%1)<28 Try it online! Based on @xnor's answer. Takes two complex numbers as input. Python 2, 42 bytes ...
loopy walt's user avatar
  • 16.7k
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 ...
Lynn's user avatar
  • 68.7k
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`" ...
Digital Trauma's user avatar
13 votes

A Numpad's Knight Numbers

Retina, 58 40 bytes Thanks to Sp3000 for suggesting this idea: M&!`.. O%`. A`16|18|27|29|34|38|49|67 ^$ Try it online! (Slightly modified to run the entire ...
Martin Ender's user avatar
13 votes

A knight's graph on an N-by-N board

MATL, 17 16 bytes t&l[2K0]B2:&ZvZ+ Try it online! (-1 byte thanks to @Luis Mendo.) The main part of the code is creating a matrix \$ K \$ for ...
Sundar R's user avatar
  • 6,612
13 votes

Greedy queens sequence

APL (Dyalog Unicode), 38 bytes 1+{⍵,⊃⍸|⊃×/×(⌽⍳≢⍵)(⊢×+×-)⍵-⊂⍳3×≢⍵}⍣⎕⊢⍬ Try it online! Kinda port of tsh's JS and Python answers. They actually need some ...
Bubbler's user avatar
  • 75.9k
13 votes

Knight to fork!

Vyxal, 50 21 19 bytes ƛk-:dẊ:RJ$Cv+C;Þf∆M Try it Online! One of the programs ever written. Luckily, there's no enpassant with horseys, so there's no bricks needed. ...
lyxal's user avatar
  • 33.2k
12 votes
Accepted

Seeking Leapers

Pyth, 41 35 hfqQu@+G+VM*s_BM*F_BMTGQ]hQ)maVhQdt Exits on error if there are no valid leapers, giving the empty string if STDERR is ignored. Try it here or run a ...
FryAmTheEggman's user avatar

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