Commits

Shlomi Fish committed c2c0408

Moved under a directory.

  • Participants
  • Parent commits a23af10

Comments (0)

Files changed (10)

not-a-not-b-not-c.txt

-Expression:                 |ABC                            |
-                            |000|001|010|011|100|101|110|111|
-----------------------------+---+---+---+---+---+---+---+---|
-~A+~B+~C                    | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 |
-----------------------------+---+---+---+---+---+---+---+---|
-~A~B~C                      | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
-----------------------------+---+---+---+---+---+---+---+---|
-A                           | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 |
-----------------------------+---+---+---+---+---+---+---+---|
-B                           | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 1 |
-----------------------------+---+---+---+---+---+---+---+---|
-C                           | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 |
-----------------------------+---+---+---+---+---+---+---+---|
-~A~B+~A~C+A~B~C             | 1   1   1   0   1   0   0   0 |
-----------------------------+---+---+---+---+---+---+---+---|
-~(AB+AC+BC)                 | 1   1   1   0   1   0   0   0 |
-----------------------------+---+---+---+---+---+---+---+---|
-~(A XOR B XOR C)            | 1   0   0   1   0   1   1   0 |
-----------------------------+---+---+---+---+---+---+---+---|
-
-~A~B + A = A + ~B
-
-A~B = A~B
-
-~A~B~C + A = A + ~B~C
-
-A(~A+~B+~C) = A~B + A~C = A (~B + ~C)
-
-B A (~B + ~C) = AB~C (and also ~ABC and A~BC )
-
-AB~C + ~ABC = C (AB~ + ~AB) = C (A XOR B)
-
-C (AB~ + ~AB) + ABC = C (AB~ + ~AB + AB) = C (A + B)
-
-C (AB~ + ~AB) + ~A~B~C = 
-
-AB~C (A + ~B~C) = AB~C
-
-AB~C (C + ~A~B) = False
-
-A + ~B~C + B = A + B + ~C
-
-(A + B + ~C) (~A + ~B + ~C) = A~B + B~A + ~C = ~C + (A XOR B)
-
-A~B + B~A + ~C + A~C + C~A + ~B = ~B + ~C + ~A (B + C)
-
-A ( ~B + ~C + ~A (B + C) ) = A~B + A~C = A (~B + ~C)
-
-AB~C + ~A~B~C = ~C (AB + ~A~B)
-
-(~B + ~C + ~A (B + C) )*(B+C) = ~BC + ~CB + ~A(B + C) = ~BC + ~CB + ~AB + ~AC
-= B (~A + ~C) + C (~A + ~B)
-
-
--------------------------
-
-Contemplating:
---------------
-
-AB~C + ~A~B~C + ~AB~C + A~B~C = ~C
-
-Alternatives:
--------------
-
-~(AB + BC + AC) = (~A + ~B)(~A + ~C)(~B + ~C) = (~A + ~B~C)(~B + ~C) = 
-
-~[(A+B)(B+C)(A+C)] = ~(A+B) + ~(B+C) + ~(A+C) = ~A~B + ~B~C + ~A~C
-
-A (~A~B + ~B~C + ~A~C) = A~B~C
-
-A~B~C + ~AB~C = ~C(A XOR B)
-
-~A~B + ~B~C + ~A~C + A = A + ~B + ~C
-
-A~B~C + ~AB~C + C = (A XOR B) + C = C + A~B + ~AB
-
-B*(C + A~B + ~AB) = BC + ~AB = B (C + ~A)
-
-BC + ~AB + ~BA + AC = C(A + B) + (A XOR B)
-
-A~B~C + B  = B + A~C
-
-(B + A~C) + (~A~B + ~B~C + ~A~C) = ~A + ~C + B
-
-(A + ~B + ~C) * (~AB~C) = ~AB~C
-
-/ ~A~B -> A + ~B ; B + ~A ; ~A~B~C ; A + ~C ; C + ~A ; ~A (~B + ~C)
-|      -> ~A~B + ~A~C
-\ ~A~C -> 
-

not-a-opt-proto.pl

-#!/usr/bin/perl
-
-use strict;
-use warnings;
-
-use List::MoreUtils qw(notall);
-
-my $limit = 0xFF;
-
-# @p is the population of the positions.
-my @p = (map { undef() } (0 .. $limit));
-
-sub neg
-{
-    return ((~(shift())) & $limit);
-}
-
-my %initial;
-
-my $A = $initial{A} = 0b11110000;
-my $B = $initial{B} = 0b11001100;
-my $C = $initial{C} = 0b10101010;
-
-my $NOT_A = neg($A);
-my $NOT_B = neg($B);
-my $NOT_C = neg($C);
-
-# $initial{NOT_AND} = ((~($initial{A} & $initial{B} & $initial{C})) & $limit);
-# $initial{NOT_OR2} = ((~($initial{A} | $initial{B} | $initial{C})) & $limit);
-# $initial{NOT_OR} = ((~(($A & $B) | ($A & $C) | ($B & $C))) & $limit);
-# $initial{B_NOT} = ((~$B) & $limit);
-# $initial{C_NOT} = ((~$C) & $limit);
-# $initial{NOT_AB} = ((~(($A | $B))) & $limit);
-# $initial{NOT_AC} = ((~(($A & $C))) & $limit);
-
-# $initial{NOT_OR} = ((~($B & ($A | $C))) & $limit);
-# $initial{NOT_AND2} = ((~($B)) & $limit);
-
-my $get = sub {
-    my $i = shift;
-
-    return $p[$i];
-};
-
-my $not_def = sub {
-    my $i = shift;
-
-    return !defined($get->($i));
-};
-
-my $set = sub {
-    my ($i, $val) = @_;
-
-    $p[$i] = $val;
-
-    return;
-};
-
-while (my ($key, $mask) = each(%initial))
-{
-    $set->($mask, ['i', $key]);
-}
-
-sub find
-{
-    POP:
-    while (notall { $get->($_) } ($NOT_A, $NOT_B, $NOT_C))
-    {
-        X_LOOP:
-        for my $x (0 .. ($limit-1))
-        {
-            if ($not_def->($x))
-            {
-                next X_LOOP;
-            }
-
-            Y_LOOP:
-            for my $y (($x+1) .. $limit)
-            {
-                if ($not_def->($y))
-                {
-                    next Y_LOOP;
-                }
-
-                my $new;
-                if ($not_def->($x & $y))
-                {
-                    $set->(($x & $y), ['&', $x, $y]);
-                    $new = 1;
-                }
-
-                if ($not_def->($x | $y))
-                {
-                    $set->(($x | $y), ['|', $x, $y]);
-                    $new = 1;
-                }
-                
-                if ($new)
-                {
-                    next POP;
-                }
-            }
-        }
-
-        return;
-    }
-    return 1;
-}
-
-find();
-
-my @start_p = @p;
-
-foreach my $i (grep { $get->($_) } 0 .. $limit)
-{
-    print "Checking $i\n";
-    
-    my $neg = neg($i);
-
-    if ($not_def->($neg))
-    {
-        @p = @start_p;
-
-        $set->($neg, ['~', $i]);
-        
-        find();
-
-        my @i_p = @p;
-
-        foreach my $j (grep { $get->($_) } (0 .. $limit))
-        {
-            my $neg_j = neg($j);
-
-            @p = @i_p;
-
-            if ($not_def->($neg_j))
-            {
-                $set->($neg_j, ['~', $j]);
-                
-                if (find())
-                {
-                    foreach my $signal (qw(A B C))
-                    {
-                        my $n = neg($initial{$signal});
-                        print "~$signal = ", disp($n), "\n";
-                    }
-                }
-            }
-        }
-    }
-}
-
-sub disp
-{
-    my $n = shift;
-
-    my $e = $p[$n];
-
-    my $proto_ret = sub { 
-    if ($e->[0] eq "i")
-    {
-        return $e->[1];
-    }
-    elsif (($e->[0] eq "&") || ($e->[0] eq "|"))
-    {
-        return "(" . disp($e->[1]) . ")$e->[0](" . disp($e->[2]) . ")";
-    }
-    elsif ($e->[0] eq "~")
-    {
-        return "~(". disp($e->[1]) . ")";
-    }
-    else
-    {
-        die "Unknown e->[0] $e->[0]!";
-    }
-    }->();
-
-    $proto_ret =~ s{\(([ABC])\)}{$1}g;
-    $proto_ret =~ s{\(([ABC])&([ABC])\)}/
-        join("",sort { $a cmp $b } ($1,$2))
-        /eg;
-    $proto_ret =~ s/\(([ABC]{2})\|\(([ABC]{2})\|([ABC]{2})\)\)/
-        "(" . join("|", sort { $a cmp $b} ($1,$2,$3)) . ")"
-        /eg;
-
-    return $proto_ret;
-}

not-a.pl

-#!/usr/bin/perl
-
-use strict;
-use warnings;
-
-use List::MoreUtils qw(all);
-
-my $limit = 0xFF;
-
-my $population =
-{ 
-    'p' => [map { undef() } (0 .. $limit)],
-};
-
-sub lim
-{
-    return (shift() & $limit);
-}
-
-my %initial;
-
-my $A = $initial{A} = 0b11110000;
-my $B = $initial{B} = 0b11001100;
-my $C = $initial{C} = 0b10101010;
-
-my $NOT_A = lim(~$A);
-my $NOT_B = lim(~$B);
-my $NOT_C = lim(~$C);
-
-# $initial{NOT_AND} = ((~($initial{A} & $initial{B} & $initial{C})) & $limit);
-# $initial{NOT_OR2} = ((~($initial{A} | $initial{B} | $initial{C})) & $limit);
-# $initial{NOT_OR} = ((~(($A & $B) | ($A & $C) | ($B & $C))) & $limit);
-# $initial{B_NOT} = ((~$B) & $limit);
-# $initial{C_NOT} = ((~$C) & $limit);
-# $initial{NOT_AB} = ((~(($A | $B))) & $limit);
-# $initial{NOT_AC} = ((~(($A & $C))) & $limit);
-
-# $initial{NOT_OR} = ((~($B & ($A | $C))) & $limit);
-# $initial{NOT_AND2} = ((~($B)) & $limit);
-
-my $get = sub {
-    my $i = shift;
-
-    return $population->{p}[$i];
-};
-
-my $not_def = sub {
-    my $i = shift;
-
-    return !defined($get->($i));
-};
-
-my $set = sub {
-    my ($i, $val) = @_;
-
-    $population->{p}[$i] = $val;
-
-    return;
-};
-
-while (my ($key, $mask) = each(%initial))
-{
-    $set->($mask, ['i', $key]);
-}
-
-sub find
-{
-    my $found;
-    POP:
-    while (! ($found = all { $get->($_) } ($NOT_A, $NOT_B, $NOT_C)))
-    {
-        X_LOOP:
-        for my $x (0 .. ($limit-1))
-        {
-            if ($not_def->($x))
-            {
-                next X_LOOP;
-            }
-
-            Y_LOOP:
-            for my $y (($x+1) .. $limit)
-            {
-                if ($not_def->($y))
-                {
-                    next Y_LOOP;
-                }
-
-                my $new;
-                if ($not_def->($x & $y))
-                {
-                    $set->(($x & $y), ['&', $x, $y]);
-                    $new = 1;
-                }
-
-                if ($not_def->($x | $y))
-                {
-                    $set->(($x | $y), ['|', $x, $y]);
-                    $new = 1;
-                }
-                
-                if ($new)
-                {
-                    next POP;
-                }
-            }
-        }
-
-        last POP;
-    }
-    return $found;
-}
-
-find();
-
-my $init_population = { p => [ @{$population->{p}} ] };
-
-my @keys = (grep { $not_def->($_) } (0 .. $limit));
-
-for my $k_i (0 .. $#keys-1)
-{
-    for my $k_j ($k_i+1 .. $#keys)
-    {
-        print "Checking $k_i and $k_j\n";
-
-        $population = { p => [ @{$init_population->{p}} ] };
-
-        $set->($keys[$k_i], ['i', 'k_i']);
-        $set->($keys[$k_j], ['i', 'k_j']);
-
-        if (find())
-        {
-            print sprintf("Found for 0b%.8b , 0b%.8b.\n", $keys[$k_i], $keys[$k_j]);
-            exit(0);
-        }
-
-    }
-}
-
-

notes.txt

-
-Mort = ~(AB|AC|BC)
-Gang = ~((Mort&A)|(Mort&B)|(Mort&C)|(ABC))
-
-# Gang == NOT ( A XOR B XOR C )
-
-~A = (Mort&Gang)|(Mort&C)|(Mort&B)|(Gang&BC)
-~B = (Mort&Gang)|(Mort&C)|(Mort&A)|(Gang&AC)
-~C = (Mort&Gang)|(Mort&B)|(Mort&A)|(Gang&AB)
-

process-proto.pl

-#!/usr/bin/perl
-
-use strict;
-use warnings;
-
-use IO::All;
-
-sub proc
-{
-    local $_ = shift;
-    
-    s/\$get->\(\$_\)/\$p[\$_]/;
-    s/\$not_def->\(([^\)]+)\)/(!defined(\$p[$1]))/;
-    s/\$set->\(([^,]+),([^\)]+)\)/\$p[$1] = $2/;
-    s/neg\(([^\)]+)\)/((~($1))&\$limit)/;
-
-    return $_;
-}
-
-io->file("not-a-opt.pl")->print(
-    map { proc($_) } io->file("not-a-opt-proto.pl")->getlines()
-);
-   

riddle-not-a-not-b-not-c/not-a-not-b-not-c.txt

+Expression:                 |ABC                            |
+                            |000|001|010|011|100|101|110|111|
+----------------------------+---+---+---+---+---+---+---+---|
+~A+~B+~C                    | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 |
+----------------------------+---+---+---+---+---+---+---+---|
+~A~B~C                      | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
+----------------------------+---+---+---+---+---+---+---+---|
+A                           | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 |
+----------------------------+---+---+---+---+---+---+---+---|
+B                           | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 1 |
+----------------------------+---+---+---+---+---+---+---+---|
+C                           | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 |
+----------------------------+---+---+---+---+---+---+---+---|
+~A~B+~A~C+A~B~C             | 1   1   1   0   1   0   0   0 |
+----------------------------+---+---+---+---+---+---+---+---|
+~(AB+AC+BC)                 | 1   1   1   0   1   0   0   0 |
+----------------------------+---+---+---+---+---+---+---+---|
+~(A XOR B XOR C)            | 1   0   0   1   0   1   1   0 |
+----------------------------+---+---+---+---+---+---+---+---|
+
+~A~B + A = A + ~B
+
+A~B = A~B
+
+~A~B~C + A = A + ~B~C
+
+A(~A+~B+~C) = A~B + A~C = A (~B + ~C)
+
+B A (~B + ~C) = AB~C (and also ~ABC and A~BC )
+
+AB~C + ~ABC = C (AB~ + ~AB) = C (A XOR B)
+
+C (AB~ + ~AB) + ABC = C (AB~ + ~AB + AB) = C (A + B)
+
+C (AB~ + ~AB) + ~A~B~C = 
+
+AB~C (A + ~B~C) = AB~C
+
+AB~C (C + ~A~B) = False
+
+A + ~B~C + B = A + B + ~C
+
+(A + B + ~C) (~A + ~B + ~C) = A~B + B~A + ~C = ~C + (A XOR B)
+
+A~B + B~A + ~C + A~C + C~A + ~B = ~B + ~C + ~A (B + C)
+
+A ( ~B + ~C + ~A (B + C) ) = A~B + A~C = A (~B + ~C)
+
+AB~C + ~A~B~C = ~C (AB + ~A~B)
+
+(~B + ~C + ~A (B + C) )*(B+C) = ~BC + ~CB + ~A(B + C) = ~BC + ~CB + ~AB + ~AC
+= B (~A + ~C) + C (~A + ~B)
+
+
+-------------------------
+
+Contemplating:
+--------------
+
+AB~C + ~A~B~C + ~AB~C + A~B~C = ~C
+
+Alternatives:
+-------------
+
+~(AB + BC + AC) = (~A + ~B)(~A + ~C)(~B + ~C) = (~A + ~B~C)(~B + ~C) = 
+
+~[(A+B)(B+C)(A+C)] = ~(A+B) + ~(B+C) + ~(A+C) = ~A~B + ~B~C + ~A~C
+
+A (~A~B + ~B~C + ~A~C) = A~B~C
+
+A~B~C + ~AB~C = ~C(A XOR B)
+
+~A~B + ~B~C + ~A~C + A = A + ~B + ~C
+
+A~B~C + ~AB~C + C = (A XOR B) + C = C + A~B + ~AB
+
+B*(C + A~B + ~AB) = BC + ~AB = B (C + ~A)
+
+BC + ~AB + ~BA + AC = C(A + B) + (A XOR B)
+
+A~B~C + B  = B + A~C
+
+(B + A~C) + (~A~B + ~B~C + ~A~C) = ~A + ~C + B
+
+(A + ~B + ~C) * (~AB~C) = ~AB~C
+
+/ ~A~B -> A + ~B ; B + ~A ; ~A~B~C ; A + ~C ; C + ~A ; ~A (~B + ~C)
+|      -> ~A~B + ~A~C
+\ ~A~C -> 
+

riddle-not-a-not-b-not-c/not-a-opt-proto.pl

+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use List::MoreUtils qw(notall);
+
+my $limit = 0xFF;
+
+# @p is the population of the positions.
+my @p = (map { undef() } (0 .. $limit));
+
+sub neg
+{
+    return ((~(shift())) & $limit);
+}
+
+my %initial;
+
+my $A = $initial{A} = 0b11110000;
+my $B = $initial{B} = 0b11001100;
+my $C = $initial{C} = 0b10101010;
+
+my $NOT_A = neg($A);
+my $NOT_B = neg($B);
+my $NOT_C = neg($C);
+
+# $initial{NOT_AND} = ((~($initial{A} & $initial{B} & $initial{C})) & $limit);
+# $initial{NOT_OR2} = ((~($initial{A} | $initial{B} | $initial{C})) & $limit);
+# $initial{NOT_OR} = ((~(($A & $B) | ($A & $C) | ($B & $C))) & $limit);
+# $initial{B_NOT} = ((~$B) & $limit);
+# $initial{C_NOT} = ((~$C) & $limit);
+# $initial{NOT_AB} = ((~(($A | $B))) & $limit);
+# $initial{NOT_AC} = ((~(($A & $C))) & $limit);
+
+# $initial{NOT_OR} = ((~($B & ($A | $C))) & $limit);
+# $initial{NOT_AND2} = ((~($B)) & $limit);
+
+my $get = sub {
+    my $i = shift;
+
+    return $p[$i];
+};
+
+my $not_def = sub {
+    my $i = shift;
+
+    return !defined($get->($i));
+};
+
+my $set = sub {
+    my ($i, $val) = @_;
+
+    $p[$i] = $val;
+
+    return;
+};
+
+while (my ($key, $mask) = each(%initial))
+{
+    $set->($mask, ['i', $key]);
+}
+
+sub find
+{
+    POP:
+    while (notall { $get->($_) } ($NOT_A, $NOT_B, $NOT_C))
+    {
+        X_LOOP:
+        for my $x (0 .. ($limit-1))
+        {
+            if ($not_def->($x))
+            {
+                next X_LOOP;
+            }
+
+            Y_LOOP:
+            for my $y (($x+1) .. $limit)
+            {
+                if ($not_def->($y))
+                {
+                    next Y_LOOP;
+                }
+
+                my $new;
+                if ($not_def->($x & $y))
+                {
+                    $set->(($x & $y), ['&', $x, $y]);
+                    $new = 1;
+                }
+
+                if ($not_def->($x | $y))
+                {
+                    $set->(($x | $y), ['|', $x, $y]);
+                    $new = 1;
+                }
+                
+                if ($new)
+                {
+                    next POP;
+                }
+            }
+        }
+
+        return;
+    }
+    return 1;
+}
+
+find();
+
+my @start_p = @p;
+
+foreach my $i (grep { $get->($_) } 0 .. $limit)
+{
+    print "Checking $i\n";
+    
+    my $neg = neg($i);
+
+    if ($not_def->($neg))
+    {
+        @p = @start_p;
+
+        $set->($neg, ['~', $i]);
+        
+        find();
+
+        my @i_p = @p;
+
+        foreach my $j (grep { $get->($_) } (0 .. $limit))
+        {
+            my $neg_j = neg($j);
+
+            @p = @i_p;
+
+            if ($not_def->($neg_j))
+            {
+                $set->($neg_j, ['~', $j]);
+                
+                if (find())
+                {
+                    foreach my $signal (qw(A B C))
+                    {
+                        my $n = neg($initial{$signal});
+                        print "~$signal = ", disp($n), "\n";
+                    }
+                }
+            }
+        }
+    }
+}
+
+sub disp
+{
+    my $n = shift;
+
+    my $e = $p[$n];
+
+    my $proto_ret = sub { 
+    if ($e->[0] eq "i")
+    {
+        return $e->[1];
+    }
+    elsif (($e->[0] eq "&") || ($e->[0] eq "|"))
+    {
+        return "(" . disp($e->[1]) . ")$e->[0](" . disp($e->[2]) . ")";
+    }
+    elsif ($e->[0] eq "~")
+    {
+        return "~(". disp($e->[1]) . ")";
+    }
+    else
+    {
+        die "Unknown e->[0] $e->[0]!";
+    }
+    }->();
+
+    $proto_ret =~ s{\(([ABC])\)}{$1}g;
+    $proto_ret =~ s{\(([ABC])&([ABC])\)}/
+        join("",sort { $a cmp $b } ($1,$2))
+        /eg;
+    $proto_ret =~ s/\(([ABC]{2})\|\(([ABC]{2})\|([ABC]{2})\)\)/
+        "(" . join("|", sort { $a cmp $b} ($1,$2,$3)) . ")"
+        /eg;
+
+    return $proto_ret;
+}

riddle-not-a-not-b-not-c/not-a.pl

+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use List::MoreUtils qw(all);
+
+my $limit = 0xFF;
+
+my $population =
+{ 
+    'p' => [map { undef() } (0 .. $limit)],
+};
+
+sub lim
+{
+    return (shift() & $limit);
+}
+
+my %initial;
+
+my $A = $initial{A} = 0b11110000;
+my $B = $initial{B} = 0b11001100;
+my $C = $initial{C} = 0b10101010;
+
+my $NOT_A = lim(~$A);
+my $NOT_B = lim(~$B);
+my $NOT_C = lim(~$C);
+
+# $initial{NOT_AND} = ((~($initial{A} & $initial{B} & $initial{C})) & $limit);
+# $initial{NOT_OR2} = ((~($initial{A} | $initial{B} | $initial{C})) & $limit);
+# $initial{NOT_OR} = ((~(($A & $B) | ($A & $C) | ($B & $C))) & $limit);
+# $initial{B_NOT} = ((~$B) & $limit);
+# $initial{C_NOT} = ((~$C) & $limit);
+# $initial{NOT_AB} = ((~(($A | $B))) & $limit);
+# $initial{NOT_AC} = ((~(($A & $C))) & $limit);
+
+# $initial{NOT_OR} = ((~($B & ($A | $C))) & $limit);
+# $initial{NOT_AND2} = ((~($B)) & $limit);
+
+my $get = sub {
+    my $i = shift;
+
+    return $population->{p}[$i];
+};
+
+my $not_def = sub {
+    my $i = shift;
+
+    return !defined($get->($i));
+};
+
+my $set = sub {
+    my ($i, $val) = @_;
+
+    $population->{p}[$i] = $val;
+
+    return;
+};
+
+while (my ($key, $mask) = each(%initial))
+{
+    $set->($mask, ['i', $key]);
+}
+
+sub find
+{
+    my $found;
+    POP:
+    while (! ($found = all { $get->($_) } ($NOT_A, $NOT_B, $NOT_C)))
+    {
+        X_LOOP:
+        for my $x (0 .. ($limit-1))
+        {
+            if ($not_def->($x))
+            {
+                next X_LOOP;
+            }
+
+            Y_LOOP:
+            for my $y (($x+1) .. $limit)
+            {
+                if ($not_def->($y))
+                {
+                    next Y_LOOP;
+                }
+
+                my $new;
+                if ($not_def->($x & $y))
+                {
+                    $set->(($x & $y), ['&', $x, $y]);
+                    $new = 1;
+                }
+
+                if ($not_def->($x | $y))
+                {
+                    $set->(($x | $y), ['|', $x, $y]);
+                    $new = 1;
+                }
+                
+                if ($new)
+                {
+                    next POP;
+                }
+            }
+        }
+
+        last POP;
+    }
+    return $found;
+}
+
+find();
+
+my $init_population = { p => [ @{$population->{p}} ] };
+
+my @keys = (grep { $not_def->($_) } (0 .. $limit));
+
+for my $k_i (0 .. $#keys-1)
+{
+    for my $k_j ($k_i+1 .. $#keys)
+    {
+        print "Checking $k_i and $k_j\n";
+
+        $population = { p => [ @{$init_population->{p}} ] };
+
+        $set->($keys[$k_i], ['i', 'k_i']);
+        $set->($keys[$k_j], ['i', 'k_j']);
+
+        if (find())
+        {
+            print sprintf("Found for 0b%.8b , 0b%.8b.\n", $keys[$k_i], $keys[$k_j]);
+            exit(0);
+        }
+
+    }
+}
+
+

riddle-not-a-not-b-not-c/notes.txt

+
+Mort = ~(AB|AC|BC)
+Gang = ~((Mort&A)|(Mort&B)|(Mort&C)|(ABC))
+
+# Gang == NOT ( A XOR B XOR C )
+
+~A = (Mort&Gang)|(Mort&C)|(Mort&B)|(Gang&BC)
+~B = (Mort&Gang)|(Mort&C)|(Mort&A)|(Gang&AC)
+~C = (Mort&Gang)|(Mort&B)|(Mort&A)|(Gang&AB)
+

riddle-not-a-not-b-not-c/process-proto.pl

+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use IO::All;
+
+sub proc
+{
+    local $_ = shift;
+    
+    s/\$get->\(\$_\)/\$p[\$_]/;
+    s/\$not_def->\(([^\)]+)\)/(!defined(\$p[$1]))/;
+    s/\$set->\(([^,]+),([^\)]+)\)/\$p[$1] = $2/;
+    s/neg\(([^\)]+)\)/((~($1))&\$limit)/;
+
+    return $_;
+}
+
+io->file("not-a-opt.pl")->print(
+    map { proc($_) } io->file("not-a-opt-proto.pl")->getlines()
+);
+