I have decided to write a solution to the
N-Queens Puzzle, one of the classic problems in computer science, in the
AEC programming language. That puzzle asks in how many ways you can arrange n chess queens
on an n-times-n chessboard without breaking the rules that no
two chess queens can be in the same row, column or diagonal.
This only works in very modern browsers. I'm not too interested in
targeting archaic browsers here. This only works in Firefox 62 and newer or
Chrome 69 and newer (those with support WebAssembly.Global).
After a few years (if not months), all JavaScript environments will become
as capable as they are, rather than like Internet Explorer.
AEC program output:
You can see the source code of the AEC program
here. It may be a little hard to
understand. If that's the case, try first understanding the
Permutations Test, as it uses the same
algorithm to solve a simpler problem.
UPDATE on 19/02/2024: I've ported this program to the x86 dialect of AEC.
The source code is available in this ZIP archive,
in the file nQueensPuzzle.aec. Or, in case you want to risk
getting a virus from my computer, you can download this
ZIP archive
which contains both the source code and the Windows executable. The x86
dialect of AEC doesn't support functions and it doesn't support structures.
I hope you can appreciate how they make the code easier to understand. The
WebAssembly version of this program uses recursion, whereas the x86 version
of this program uses the stack instead of recursion.
UPDATE on 21/03/2024: I've started learning the Dart programming language
and have ported this program to Dart. It
uses an algorithm similar to the one used in the x86 AEC N Queens Puzzle
solution, except that the stack is a two-dimensional list.