#!/usr/bin/perl
@NewNum=[1];
for (1) {
@Num = @NewNum;
@NewNum = [];
print (@Num,"\n");
for ($count = 0; $count++; $count < (@Num)) {
$CurrentDigit = $Num[$count];
$NextDigit = $Num[$count+1];
if ($CurrentDigit = 1) {
if ($NextDigit = 1) {
@NewNum = [@NewNum,2,1]
$count++;
} else {
@NewNum = [@NewNum,1,1]
}
} else {
@NewNum = [@NewNum,1,2]
}
}
}
1 => 11
11 => 21
21 => 1211
1211 => 111221
111221 => 2111121211
2111121211 => 12212112111221
Prolly not right, but it fits the starting list. In English... A 1 not followed by a 1 gets
lonely, so it calls over another 1 to be next to it. A 1 followed by a 1 is
happy, too much so, and it turns into a 2. The 1 immediately following the new 2 is too
stunned to do anything.
A 2 wishes it could be a 1 again, and it puts a 1 in front of itself. Every number gets one reaction, either calling over another number, changing, or being stunned, in order from left to right.