# riddle-not-a-not-b-not-c

committed 77bd532

Add the not-a-opt-proto.pl program and a script to process it.

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

----------------------------+---+---+---+---+---+---+---+---|
C                           | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 |
----------------------------+---+---+---+---+---+---+---+---|
-
+~A~B+~A~C+A~B~C             | 1   1   1   0   1   0   0   0 |
+----------------------------+---+---+---+---+---+---+---+---|
~A~B + A = A + ~B

A~B = A~B

# not-a-opt-proto.pl

use strict;
use warnings;

-use List::MoreUtils qw(all);
+use List::MoreUtils qw(notall);

my \$limit = 0xFF;

sub find
{
-    my \$found;
POP:
-    while (! (\$found = all { \$get->(\$_) } (\$NOT_A, \$NOT_B, \$NOT_C)))
+    while (notall { \$get->(\$_) } (\$NOT_A, \$NOT_B, \$NOT_C))
{
X_LOOP:
for my \$x (0 .. (\$limit-1))
}
}

-        last POP;
+        return;
}
-    return \$found;
+    return 1;
}

find();

for my \$k_i (0 .. \$#keys-1)
{
+    print "Checking \$k_i\n";
for my \$k_j (\$k_i+1 .. \$#keys)
{
-        print "Checking \$k_i and \$k_j\n";
-
@p = @start_p;

\$set->(\$keys[\$k_i], ['i', 'k_i']);
if (find())
{
print sprintf("Found for 0b%.8b , 0b%.8b.\n", \$keys[\$k_i], \$keys[\$k_j]);
-            exit(0);
}

}

# 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/;
+
+    return \$_;
+}
+
+io->file("not-a-opt.pl")->print(
+    map { proc(\$_) } io->file("not-a-opt-proto.pl")->getlines()
+);
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.