# rhoScript Example

The following translation visualisation example is for rhoScript, a new "golfing" language invented by Nicholas Carlini.

Code Golf is all about writing programs which are as short as possible. So one should not be surprised if any attempted English translation of a rhoScript program is much longer than the original.

## The Eight Queens Puzzle

The example shown here is a rhoScript program that solves the Eight Queens Puzzle. The question to be answered is: "How many different ways can 8 queens be placed on a chessboard such that none of them attack each other?" (if you don't know much about chess, this means that no two queens are on the same row, column or diagonal).

A brief summary of the solution is as follows:

• Number the queens from 0 to 7 (instead of 1 to 8, because that's how computer programmers like to do these things).
• Assign X and Y co-ordinates from 0 to 7 for each of the 8 rows and 8 columns.
• Let i be the X coordinate of the ith queen in each case, and let the corresponding value in the permutation be the Y coordinate. Call this set of positions an arrangement. Deriving the arrangement in this manner from a permutation ensures that no two queens are on the same row or column. Also, any arrangement of 8 queen's not sharing any rows or columns must correspond to such a permutation.
• Count how many diagonals (in both directions) are occupied by the queens.
• Do this for all possible permutations.
• Determine the maximum number of diagonals that can be occupied. (If any solutions exist, this maximum must be 16.)
• Return the set of permutations for which the maximum number of diagonals is occupied.

The Correspondence-Bracketup source code can be seen in the source code of this web page.