Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -1,16 +1,16 @@
[([Int] -> Bool)] predicates
predicates [+]= st -> st.len == 12
predicates [+]= st -> sum(st[(len)-6 ..]) == 3
predicates [+]= st -> sum(st[(1..).step(2)]) == 2
predicates [+]= st -> I st[4] {(st[5] [&] st[6])} E 1
predicates [+]= st -> sum(st[1.<4]) == 0
predicates [+]= st -> sum(st[(0..).step(2)]) == 4
predicates [+]= st -> sum(st[1.<3]) == 1
predicates [+]= st -> I st[6] {(st[4] [&] st[5])} E 1
predicates [+]= st -> sum(st[0.<6]) == 3
predicates [+]= st -> (st[10] [&] st[11])
predicates [+]= st -> sum(st[6.<9]) == 1
predicates [+]= st -> sum(st[0.<11]) == 4
predicates.append(st -> st.len == 12)
predicates.append(st -> sum(st[(len)-6 ..]) == 3)
predicates.append(st -> sum(st[(1..).step(2)]) == 2)
predicates.append(st -> I st[4] {(st[5] [&] st[6])} E 1)
predicates.append(st -> sum(st[1.<4]) == 0)
predicates.append(st -> sum(st[(0..).step(2)]) == 4)
predicates.append(st -> sum(st[1.<3]) == 1)
predicates.append(st -> I st[6] {(st[4] [&] st[5])} E 1)
predicates.append(st -> sum(st[0.<6]) == 3)
predicates.append(st -> (st[10] [&] st[11]))
predicates.append(st -> sum(st[6.<9]) == 1)
predicates.append(st -> sum(st[0.<11]) == 4)
F to_str(b)
R (0.<12).filter(i -> @b[i]).map(i -> i + 1).join( )
@ -18,7 +18,7 @@ F to_str(b)
print(Exact hits:)
L(n) 0 .< (1 << 12)
V bools = [0] * 12
L(i) 12
L(i) 0.<12
I n [&] (1 << (11 - i)) != 0
bools[i] = 1
@ -31,7 +31,7 @@ L(n) 0 .< (1 << 12)
print("\nNear misses:")
L(n) 0 .< (1 << 12)
V bools = [0] * 12
L(i) 12
L(i) 0.<12
I n [&] (1 << (11 - i)) != 0
bools[i] = 1

View file

@ -1,79 +0,0 @@
with Ada.Text_IO, Logic;
procedure Twelve_Statements is
package L is new Logic(Number_Of_Statements => 12); use L;
-- formally define the 12 statements as expression function predicates
function P01(T: Table) return Boolean is (T'Length = 12); -- list of 12 statements
function P02(T: Table) return Boolean is (Sum(T(7 .. 12)) = 3); -- three of last six
function P03(T: Table) return Boolean is (Sum(Half(T, Even)) = 2); -- two of the even
function P04(T: Table) return Boolean is (if T(5) then T(6) and T(7)); -- if 5 is true, then ...
function P05(T: Table) return Boolean is
( (not T(2)) and (not T(3)) and (not T(4)) ); -- none of preceding three
function P06(T: Table) return Boolean is (Sum(Half(T, Odd)) = 4); -- four of the odd
function P07(T: Table) return Boolean is (T(2) xor T(3)); -- either 2 or 3, not both
function P08(T: Table) return Boolean is (if T(7) then T(5) and T(6)); -- if 7 is true, then ...
function P09(T: Table) return Boolean is (Sum(T(1 .. 6)) = 3); -- three of first six
function P10(T: Table) return Boolean is (T(11) and T(12)); -- next two
function P11(T: Table) return Boolean is (Sum(T(7..9)) = 1); -- one of 7, 8, 9
function P12(T: Table) return Boolean is (Sum(T(1 .. 11)) = 4); -- four of the preding
-- define a global list of statements
Statement_List: constant Statements :=
(P01'Access, P02'Access, P03'Access, P04'Access, P05'Access, P06'Access,
P07'Access, P08'Access, P09'Access, P10'Access, P11'Access, P12'Access);
-- try out all 2^12 possible choices for the table
procedure Try(T: Table; Fail: Natural; Idx: Indices'Base := Indices'First) is
procedure Print_Table(T: Table) is
use Ada.Text_IO;
begin
Put(" ");
if Fail > 0 then
Put("(wrong at");
for J in T'Range loop
if Statement_List(J)(T) /= T(J) then
Put(Integer'Image(J) & (if J < 10 then ") " else ") "));
end if;
end loop;
end if;
if T = (1..12 => False) then
Put_Line("All false!");
else
Put("True are");
for J in T'Range loop
if T(J) then
Put(Integer'Image(J));
end if;
end loop;
New_Line;
end if;
end Print_Table;
Wrong_Entries: Natural := 0;
begin
if Idx <= T'Last then
Try(T(T'First .. Idx-1) & False & T(Idx+1 .. T'Last), Fail, Idx+1);
Try(T(T'First .. Idx-1) & True & T(Idx+1 .. T'Last), Fail, Idx+1);
else -- now Index > T'Last and we have one of the 2^12 choices to test
for J in T'Range loop
if Statement_List(J)(T) /= T(J) then
Wrong_Entries := Wrong_Entries + 1;
end if;
end loop;
if Wrong_Entries = Fail then
Print_Table(T);
end if;
end if;
end Try;
begin
Ada.Text_IO.Put_Line("Exact hits:");
Try(T => (1..12 => False), Fail => 0);
Ada.Text_IO.New_Line;
Ada.Text_IO.Put_Line("Near Misses:");
Try(T => (1..12 => False), Fail => 1);
end Twelve_Statements;

View file

@ -1,16 +0,0 @@
generic
Number_Of_Statements: Positive;
package Logic is
--types
subtype Indices is Natural range 1 .. Number_Of_Statements;
type Table is array(Indices range <>) of Boolean;
type Predicate is access function(T: Table) return Boolean;
type Statements is array(Indices) of Predicate;
type Even_Odd is (Even, Odd);
-- convenience functions
function Sum(T: Table) return Natural;
function Half(T: Table; Which: Even_Odd) return Table;
end Logic;

View file

@ -1,27 +0,0 @@
package body Logic is
function Sum(T: Table) return Natural is
Result: Natural := 0;
begin
for I in T'Range loop
if T(I) then
Result := Result + 1;
end if;
end loop;
return Result;
end Sum;
function Half(T: Table; Which: Even_Odd) return Table is
Result: Table(T'Range);
Last: Natural := Result'First - 1;
begin
for I in T'Range loop
if I mod 2 = (if (Which=Odd) then 1 else 0) then
Last := Last+1;
Result(Last) := T(I);
end if;
end loop;
return Result(Result'First .. Last);
end Half;
end Logic;

View file

@ -41,9 +41,9 @@ puzzle = new Func1[]
(bits => bits.top(11).selectBy::(x => x.toBit()).summarize() == 4 )
};
public program()
public Program()
{
console.writeLine();
Console.writeLine();
for(int n := 0; n < 2.power(12); n += 1)
{
@ -53,10 +53,10 @@ public program()
var counts := bits.zipBy(results, (b,r => b.xor(r).toBit() )).summarize();
counts =>
0 { console.printLine("Total hit :",results.printSolution(bits)) }
1 { console.printLine("Near miss :",results.printSolution(bits)) }
12 { console.printLine("Total miss:",results.printSolution(bits)) };
0 : { Console.printLine("Total hit :",results.printSolution(bits)) }
1 : { Console.printLine("Near miss :",results.printSolution(bits)) }
12: { Console.printLine("Total miss:",results.printSolution(bits)) };
};
console.readChar()
Console.readChar()
}