The 15 Puzzle


Code

	l:("Click on any of the pieces next to the space, and"
	   "that piece will slide over the space.  Continue  "
	   "this until the pieces are arranged in numerical  "
	   "order from upper-left to lower-right.            ")
	l.[`l`e]:`,0

	m:4 4#2$'(1+15_draw-15),0N
	m.[`l`x`k]:`,15,,"move _i"

	move:{if[1=+/_abs x-p:,/(&|/)'(+:;::)@\:&/''m=" ";(p;x).[`m;;:;]'(m . x;"  ")]}

	Dismiss:"`hide$`.k"
	Code:"`show$0:`puzzle.k;"
	Dismiss..c:Code..c:`button

	.k..l:"15-Puzzle Demonstration"
	.k..a:`l,`m,,`Dismiss`Code
	`show$`.k

GUI