Data update

This commit is contained in:
Ingy döt Net 2024-07-13 15:19:22 -07:00
parent 29a5eea0d4
commit 5c1bb7bfa9
2011 changed files with 35081 additions and 3229 deletions

View file

@ -0,0 +1,51 @@
Dim As String txt = "" _
" A B" & Chr(10) & _
" /|\ /|\" & Chr(10) & _
" / | X | \" & Chr(10) & _
" / |/ \| \" & Chr(10) & _
" C - D - E - F" & Chr(10) & _
" \ |\ /| /" & Chr(10) & _
" \ | X | /" & Chr(10) & _
" \|/ \|/" & Chr(10) & _
" G H"
Dim Shared As String links(1 To 8)
links(1) = "": links(2) = "": links(3) = "A": links(4) = "ABC"
links(5) = "ABD": links(6) = "BE": links(7) = "CDE": links(8) = "DEF"
Sub ReplaceString(Byref cad As String, oldChar As String, newChar As String)
Dim As Integer posic
Do
posic = Instr(cad, oldChar)
If posic = 0 Then Exit Do
cad = Left(cad, posic - 1) & newChar & Mid(cad, posic + 1)
Loop
End Sub
Function solve(s As String, idx As Integer, part As String) As String
Dim As Integer v, p, i, j
Dim As String res
For i = 1 To Len(s)
v = Val(Mid(s, i, 1))
For j = 1 To Len(links(idx))
p = Asc(Mid(links(idx), j, 1)) - 64
If Abs(v - Val(Mid(part, p, 1))) < 2 Then v = 0: Exit For
Next j
If v <> 0 Then
If Len(s) = 1 Then Return part + Chr(48 + v)
res = solve(Left(s, i - 1) & Mid(s, i + 1), idx + 1, part & Chr(48 + v))
If Len(res) > 0 Then Return res
End If
Next i
Return ""
End Function
Dim As String result = solve("12345678", 1, "")
For i As Integer = 1 To Len(result)
ReplaceString(txt, Chr(64 + i), Mid(result, i, 1))
Next i
Print txt
Sleep

View file

@ -0,0 +1,24 @@
[ ' [ [ 0 2 ] [ 0 3 ] [ 0 4 ]
[ 1 3 ] [ 1 4 ] [ 1 5 ]
[ 6 2 ] [ 6 3 ] [ 6 4 ]
[ 7 3 ] [ 7 4 ] [ 7 5 ]
[ 2 3 ] [ 3 4 ] [ 4 5 ] ] ] is connections ( --> [ )
[ dip dup do
unrot peek dip peek - abs 1 = ] is invalid ( [ [ --> b )
[ true swap
connections witheach
[ dip dup invalid if
[ dip not conclude ] ]
drop ] is allvalid ( [ --> b )
say " A B C D E F G H" cr
8 ! times
[ i^ 8 rank->perm
allvalid if
[ sp
i^ 8 rank->perm
witheach
[ sp 1+ echo ]
cr conclude ] ]

View file

@ -0,0 +1,53 @@
const std = @import("std");
const print = std.debug.print;
const PA = 0;
const PB = 1;
const PC = 2;
const PD = 3;
const PE = 4;
const PF = 5;
const PG = 6;
const PH = 7;
const Pair = struct { u8, u8 };
const Pairs = [_]Pair{ .{ PA, PC }, .{ PA, PD }, .{ PA, PE }, .{ PB, PD }, .{ PB, PE }, .{ PB, PF }, .{ PC, PG }, .{ PC, PD }, .{ PD, PE }, .{ PD, PG }, .{ PD, PH }, .{ PE, PG }, .{ PE, PH }, .{ PF, PH }, .{ PE, PF } };
var t: [8]u32 = .{0} ** 8;
inline fn abs(p: Pair) u32 {
if (t[p.@"0"] < t[p.@"1"]) return t[p.@"1"] - t[p.@"0"];
return t[p.@"0"] - t[p.@"1"];
}
fn check() bool {
var r: bool = true;
for (Pairs) |p| {
r = r and abs(p) > 1;
if (!r) break;
}
return r;
}
fn has(a: u32) bool {
for (t) |v| {
if (v == a) return true;
}
return false;
}
fn solve(lvl: u32) bool {
if (lvl == 8) return check();
for (1..9) |v| {
if (has(v)) continue;
t[lvl] = v;
if (solve(lvl + 1)) return true;
}
t[lvl] = 0;
return false;
}
pub fn main() void {
_ = solve(0);
print("{{ A, B, C, D, E, F, G, H }} = {any}", .{t});
}

View file

@ -0,0 +1,54 @@
const std = @import("std");
const print = std.debug.print;
const PA = 0;
const PB = 1;
const PC = 2;
const PD = 3;
const PE = 4;
const PF = 5;
const PG = 6;
const PH = 7;
const Pair = struct { u8, u8 };
const Pairs = [_]Pair{ .{ PA, PC }, .{ PA, PD }, .{ PA, PE }, .{ PB, PD }, .{ PB, PE }, .{ PB, PF }, .{ PC, PG }, .{ PC, PD }, .{ PD, PE }, .{ PD, PG }, .{ PD, PH }, .{ PE, PG }, .{ PE, PH }, .{ PF, PH }, .{ PE, PF } };
var t: [8]u32 = .{0} ** 8;
inline fn abs(p: Pair) u32 {
if (t[p.@"0"] < t[p.@"1"]) return t[p.@"1"] - t[p.@"0"];
return t[p.@"0"] - t[p.@"1"];
}
fn check() bool {
var r: bool = true;
for (Pairs) |p| {
r = r and abs(p) > 1;
if (!r) break;
}
return r;
}
fn has(a: u32) bool {
for (t) |v| {
if (v == a) return true;
}
return false;
}
fn solve(lvl: u32) bool {
if (lvl == 8) return check();
for (1..9) |v| {
if (has(v)) continue;
t[lvl] = v;
if (solve(lvl + 1)) {
print("{{ A, B, C, D, E, F, G, H }} = {any}\n", .{t});
}
}
t[lvl] = 0;
return false;
}
pub fn main() void {
_ = solve(0);
}