Nonoblock: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 973:
No solution
</pre>
 
=={{header|M2000 Interpreter}}==
<lang M2000 Interpreter>
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)
While Block {
Block$=Array$(Block)
TotalBlocksLength+=Blen(Array$(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
</lang>
 
{{out}}
<pre style="height:30ex;overflow:scroll">
Nonoblock
1. Cells=5 |A|A| |B|
1 |A|A|_|B|_|
2 |A|A|_|_|B|
3 |_|A|A|_|B|
2. Cells=5 Empty
1 |_|_|_|_|_|
3. Cells=10 |A|A|A|A|A|A|A|A|
1 |A|A|A|A|A|A|A|A|_|_|
2 |_|A|A|A|A|A|A|A|A|_|
3 |_|_|A|A|A|A|A|A|A|A|
4. Cells=15 |A|A| |B|B|B| |C|C| |D|D|D|
1 |A|A|_|B|B|B|_|C|C|_|D|D|D|_|_|
2 |A|A|_|B|B|B|_|C|C|_|_|D|D|D|_|
3 |A|A|_|B|B|B|_|C|C|_|_|_|D|D|D|
4 |A|A|_|B|B|B|_|_|C|C|_|D|D|D|_|
5 |A|A|_|B|B|B|_|_|C|C|_|_|D|D|D|
6 |A|A|_|B|B|B|_|_|_|C|C|_|D|D|D|
7 |A|A|_|_|B|B|B|_|C|C|_|D|D|D|_|
8 |A|A|_|_|B|B|B|_|C|C|_|_|D|D|D|
9 |A|A|_|_|B|B|B|_|_|C|C|_|D|D|D|
10 |A|A|_|_|_|B|B|B|_|C|C|_|D|D|D|
11 |_|A|A|_|B|B|B|_|C|C|_|D|D|D|_|
12 |_|A|A|_|B|B|B|_|C|C|_|_|D|D|D|
13 |_|A|A|_|B|B|B|_|_|C|C|_|D|D|D|
14 |_|A|A|_|_|B|B|B|_|C|C|_|D|D|D|
15 |_|_|A|A|_|B|B|B|_|C|C|_|D|D|D|
5. Cells=5 |A|A| |B|B|B|
Impossible
 
</pre >
 
=={{header|Phix}}==
Anonymous user