Rosetta Code
maXbox Starter Tutorial 169
Rosetta Code is a programming chrestomathy site. The idea is to present solutions to the same task in as many different languages as possible, to demonstrate how languages are similar and different, and to aid a person with a grounding in one approach to a problem in learning another. Rosetta Code currently has 1,342 tasks, 400 draft tasks, and is aware of 988 languages, though we do not (and cannot) have solutions to every task in every language.
We will show that in 5 Examples.
1. Cyclops numbers — Rosetta Code
A cyclops number is a number with an odd number of digits that has a zero in the center, but nowhere else. They are named so in tribute to the one eyed giants Cyclops from Greek mythology.
Cyclops numbers can be found in any base. This task strictly is looking for those cyclops numbers in base 10.
2. Damm algorithm
The Damm algorithm is a checksum algorithm which detects all single digit errors and adjacent transposition errors. Verify the checksum, stored as last digit of an input.
https://rosettacode.org/wiki/Damm_algorithm#Pascal https://sourceforge.net/projects/maxbox5/files/examples/1468_damm_algol.txt/download
function Damm(s : string) : BOOLEAN; VAR interim,i : Byte; //UInt8; BEGIN interim := 0; i := 1; WHILE i <= length(s) DO Begin interim := b[interim][ORD(s[i])-ORD('0')]; INC(i); END; result:= interim=0; END;function Damm(s : string) : BOOLEAN;
VAR interim,i : Byte; //UInt8;
BEGIN
interim := 0;
i := 1;
WHILE i <= length(s) DO Begin
interim := b[interim][ORD(s[i])-ORD('0')];
INC(i);
END;
result:= interim=0;
END;debug: 4- 4294967295 err:0
🙂
5724 is valid
5727 is invalid
112946 is valid
112949 is invalid
mX5🐞 executed: 23/02/2026 10:11:12 Runtime: 0:0:2.375 Memload: 65% use
3. Chessgrains
Calculate the number of grains of wheat on a chessboard given that the number on each square doubles.
There once was a wise servant who saved the life of a prince. The king promised to pay whatever the servant could dream up. Knowing that the king loved chess, the servant told the king he would like to have grains of wheat. One grain on the first square of a chess board, with the number of grains doubling on each successive square.
There are 64 squares on a chessboard (where square 1 has one grain, square 2 has two grains, and so on).
Get Max Kleiner’s stories in your inbox
Join Medium for free to get updates from this writer.
Write code that shows: how many grains were on a given square, and the total number of grains on the chessboard
for it:= 1 to 64 do writ(bigpow(2,it)) 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608 16777216 33554432 67108864 134217728 268435456 536870912 1073741824 2147483648 4294967296 8589934592 17179869184 34359738368 68719476736 137438953472 274877906944 549755813888 1099511627776 2199023255552 4398046511104 8796093022208 17592186044416 35184372088832 70368744177664 140737488355328 281474976710656 562949953421312 1125899906842624 2251799813685248 4503599627370496 9007199254740992 18014398509481984 36028797018963968 72057594037927936 144115188075855872 288230376151711744 576460752303423488 1152921504606846976 2305843009213693952 4611686018427387904 9223372036854775808 18446744073709551616for it:= 1 to 64 do writ(bigpow(2,it))mX5🐞 executed: 23/02/2026 10:18:35 Runtime: 0:0:5.55 Memload: 68% use
This problem is a classic illustration of exponential growth. While the starting number is small, the repeated doubling leads to a staggering final total.
4. Cut_a_rectangle
A given rectangle is made from m × n squares. If m and n are not both odd, then it is possible to cut a path through the rectangle along the square edges such that the rectangle splits into two connected pieces with the same shape (after rotating one of the pieces by 180°). All such paths for 2 × 2 and 4 × 3 rectangles are shown below.
Write a program that calculates the number of different ways to cut an m × n rectangle. Optionally, show each of the cuts.
initTabledir(); for y:= 1 to 8 do for x:= 1 to y do if not Odd(x) or not Odd(y) then begin writeln(format('%d x %d: %d', [y, x, msolve(y, x, true) ])); //writ(inttostr64(msolve(y, x, true) )) end;initTabledir();
for y:= 1 to 8 do
for x:= 1 to y do
if not Odd(x) or not Odd(y) then begin
writeln(format('%d x %d: %d', [y, x, msolve(y, x, true) ]));
//writ(inttostr64(msolve(y, x, true) ))
end; https://sourceforge.net/projects/maxbox5/files/examples/1469_cut_a_rectangle1.txt/download Cut a rectangle — Rosetta Code
5. CubicSpecialPrimes
n is smallest prime such that the difference of successive terms are the smallest cubics of positive integers, where n < 15000.
Cubic special primes — Rosetta Code https://sourceforge.net/projects/maxbox5/files/examples/1470_CubicSpecialPrimes1.txt/download
Here’s another program answering fairly meaningless questions but providing a good programming exercise with a little math mixed in.
CheatSheet: https://claude.ai/public/artifacts/11968d9f-d02c-4183-a7aa-68dcfefd382e Mindmap: https://claude.ai/public/artifacts/8a58da49-1753-4522-b0a2-8207942b300e
Originally published at http://maxbox6.wordpress.com on February 23, 2026.







