Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,55 @@
Module NonoBlock {
Form 80,40
Flush
Print "Nonoblock"
Data 5, (2, 1)
Data 5, (,)
Data 10, (8,)
Data 15, (2,3,2,3)
Data 5, (2,3)
Def BLen(a$)=(Len(a$)-1)/2
Function UseLetter(arr) {
Dim Base 0, Res$(Len(arr))
Link Res$() to Res()
Def Ord$(a$)=ChrCode$(Chrcode(a$)+1)
L$="A"
i=each(arr)
While i {
Res$(i^)=String$("|"+L$, Array(i))+"|"
L$=Ord$(L$)
}
=Res()
}
Count=0
For i=1 to 5
Read Cells, Blocks
Blocks=UseLetter(Blocks)
Print str$(i,"")+".", "Cells=";Cells, "", iF(len(Blocks)=0->("Empty",), Blocks)
PrintRow( "|", Cells, Blocks, &Count)
CheckCount()
Next I
Sub CheckCount()
If count=0 Then Print " Impossible"
count=0
End Sub
Sub PrintRow(Lpart$, Cells, Blocks, &Comp)
If len(Blocks)=0 Then Comp++ :Print Format$("{0::-3} {1}", Comp, lpart$+String$("_|", Cells)): Exit Sub
If Cells<=0 Then Exit Sub
Local TotalBlocksLength=0, Sep_Spaces=-1
Local Block=Each(Blocks), block$
While Block {
Block$=Array$(Block)
TotalBlocksLength+=Blen(Block$)
Sep_Spaces++
}
Local MaxLengthNeed=TotalBlocksLength+Sep_Spaces
If MaxLengthNeed>Cells Then Exit Sub
block$=Array$(Car(Blocks))
local temp=Blen(block$)
block$=Mid$(Block$, 2)
If Len(Blocks)>1 Then block$+="_|" :temp++
PrintRow(Lpart$+block$, Cells-temp, Cdr(Blocks), &Comp)
PrintRow(lpart$+String$("_|", 1), Cells-1,Blocks, &Comp)
End Sub
}
NonoBlock

View file

@ -0,0 +1,90 @@
Module Nonoblock (n, m) {
Print "Cells:",n," Blocks:",m
Dim n(1 to n), m(1 to m), sp(1 to m*2), sk(1 to m*2), part(1 to m)
queue=0
If m>0 Then {
Print "Block Size:",
For i=1 to m {
Read m(i)
Print m(i),
}
Print
part(m)=m(m)
If m>1 Then {
For i=m-1 to 1 {
part(i)=m(i)+part(i+1)+1
}
}
}
If part(1)>n Then {
Print "Impossible"
} Else {
p1=0
l=0
Counter=0
While p1<=n-part(1) {
k=0
p=p1+1
For i=1 to n {
n(i)=0
}
flag=True
Repeat {
While k<m {
k++
l=0
While l<m(k) and p<=n {
l++
n(p)=1
p++
}
If p<n Then {
n(p)=0
p++
If k<m Then {
If p+part(k+1)<n+1 Then {
queue++
sp(queue)=p
sk(queue)=k
}
}
}
}
flag=True
If l=m(k) Then {
counter++
Print Str$(counter,"0000 ");
For i=1 to n {
Print n(i);" ";
}
Print
If queue>0 Then {
p=sp(queue)
k=sk(queue)
queue--
For i=p to n {
n(i)=0
}
p++
If k<m Then {
If p+part(k+1)<n+1 Then {
queue++
sp(queue)=p
' sk(queue)=k
}
}
flag=False
}
}
} Until flag
p1++
If k=0 Then Exit
}
}
}
Nonoblock 5,2,2,1
Nonoblock 5,0
Nonoblock 10,1,8
Nonoblock 15,4,2,3,2,3
Nonoblock 5,2,3,2