Hello ,
Here are three stepts that I would like to speed up - if possible:
STEP 1: I am generating an array, containing binary numbers up to a certain amount of digits. My script adds leading zeros, so that each number has equal amount of digits.
Example: 14 digit Binary array:
I am using the code
For $i = 0 to 2^$bit-1 ; $bit amount of digits. for example: 14
$binary = ( Dec2Bin($i) ) ; Check length of binary string
$adig = $bit - String

I found the question to be an uncommon and interesting problem in non-trivial combinatorics.
Here's how I would approach it. I use fixed-pitch font for readability of alignments.
I'll first list how to tackle small value of bit size, then deduce rules that can prune the tree.
Say you consider binary values in natural increasing order.
Say you call a value acceptable when it is the smallest value resulting from bit rotation of binary string of a given size.
Re