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,18 @@
void local fn FloydsTriangle( rows as int )
int col, row, num = 1
printf @"%d rows:", rows
for row = 1 to rows
for col = 1 to row
printf @"%4d\b", num
num++
next
print
next
print
end fn
fn FloydsTriangle( 5 )
fn FloydsTriangle( 14 )
HandleEvents

View file

@ -0,0 +1,19 @@
procedure FloydTriangle(rows: integer);
begin
var r := 1;
for var i:=1 to rows do
begin
for var j:=1 to i do
begin
Write(r: (j>8 ? 4 : 3));
r += 1;
end;
Writeln
end;
end;
begin
FloydTriangle(5);
Writeln;
FloydTriangle(14);
end.

View file

@ -1,19 +1,13 @@
Floyd ← ⇌⍥(⊂⍚(+⇡∩(+1)⊃⧻(⊢⇌))⊢.):{[1]}-1
JoinUsing ← ↘1/◇⊂≡(□◇⊂)↯:⊙(⧻.)□
PadL ← ⊂/⊂↯:" "
Lengths ← ⍚∵◇∵(⧻°⋕)°□
PrintIt ← (
# Create table of [last row sizes] [this row sizes] [this row numbers]
⊢⊞⊂⊢⊢↙¯1.⍉[Lengths.]
Floyd ← ⊜□⇌/(⊂↯.:)⟜(+1⇡/+)+1⇡
Print ← (
≡(□≡(°⋕)) # Stringify terms.
≡(⊢⬚""↯⊟∞:°□)⟜(◇/↥⧻) # Pad rows with "" to same dims.
≡⊟¤+1≡◇⧻⊡¯1. # Find pads and couple with each.
≡(
# Calculate last row sizes - this row sizes and use to calculate paddings
⍉⊟⊃(-:↙:⊙(⧻.)∩°□°⊟↙2)(°⋕°□⊢↘2)
&pJoinUsing " " ≡(⍚PadL°⊟)
≡(□/◇⊂↙¯⟜(⊂↯⊙@ )∩°□°⊟)⍉ # Prepad each term.
&p/⍚⊂ # Join each row and print.
)
)
PrintIt Floyd 4
PrintIt Floyd 14
Print Floyd 4
&p""
Print Floyd 14