|
|
|
|
|
by justinator
2742 days ago
|
|
I read it in art school (swiped from my then-girlfriend's bookshelf), and it was nice to have a connection between my school of art weirdos and putting myself through the same school by teaching myself software engineering. I distinctly remembering writing a Perl script to highlight that the Mu puzzle is unsolvable. #!/usr/bin/perl -w
use strict;
my %tried = ();
main();
sub main {
my @rules = (
\&rule_one,
\&rule_two,
\&rule_three,
\&rule_four,
);
my $axiom = 'MI';
my @path;
my @tries;
solve($axiom, \@rules);
}
sub solve {
my @app;
my ($axiom, $rules) = @_;
my $i = 0;
foreach(@$rules){
my $tmp = $_->($axiom);
push(@app, $tmp) if $tmp;
}
foreach(@app){
next if $tried{$_};
next unless (length($_) < 1000);
print $_ . "\n";
$tried{$_} = 1;
if($_ eq 'MU'){
print "YES!\n\n\n";
exit;
}
solve($_, $rules);
}
}
sub rule_one {
# If any string ends in I, you can append U
my $str = shift;
if ($str =~ m/I$/){
return $str . 'U';
}else{
return undef;
}
}
sub rule_two {
# If any string begins with M,
# you can duplicate the string after M,
my $str = shift;
if($str =~ /^M/){
return 'M' . substr($str, 1) . substr($str, 1);
}else{
return undef;
}
}
sub rule_three {
# If any string contains III,
# you can replace the III with U
my $str = shift;
if($str =~ /III/){
$str =~ s/III/U/g;
return $str;
}else{
return undef;
}
}
sub rule_four {
#If any string contains UU,
# you can delete the UU
my $str = shift;
if($str =~ /UU/){
$str =~ s/UU//g;
return $str;
}else{
return undef;
}
}
|
|