git @ Cat's Eye Technologies Dipple / master perl / kolakoski-b1
master

Tree @master (Download .tar.gz)

kolakoski-b1 @masterraw · history · blame

#!/usr/bin/perl

# SPDX-FileCopyrightText: Chris Pressey, the original author of this work, has dedicated it to the public domain.
# For more information, please refer to <https://unlicense.org/>
# SPDX-License-Identifier: Unlicense

my $k = "122112122122112112212112122";

my $s = ' ';
my $state = '1';

my $inspect;
my $count;
my $gen;
my $n = 1;
my $t = 16384;

my $target = "122122122122122122";

#print "K   : $k...\n";
#while ($n <= $t) {
while (length($s) <= 10000000) {
	$inspect = substr $s, $n, 1;
	if ($inspect eq ' ') { $count = 1; } else { $count = 2; }
	if ($state eq '1') { $gen = '*'; } else { $gen = ' '; }
	$gen = $gen x $count;
	$s .= $gen;
	my $l = length($s);
	if ($n % 10000 == 0) {
		my $lab = sprintf("%4d", $n);
		my $d = $l-$n;
		print "n=$n, |s|=$l, |s|-$n=$d\n";
	}
	# print "$lab: $s\n";
	#if (index($s, $target) != -1) {
	#	print "FOUND\n";
	#	exit;
	#}
	if ($state eq '1') { $state = '2'; } else { $state = '1'; }
	$n++;
}

#print "$s\n";