Data update

This commit is contained in:
Ingy döt Net 2024-10-16 18:07:41 -07:00
parent 81fd053722
commit 52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions

View file

@ -0,0 +1,58 @@
Sub patienceSort(bs() As Long)
Dim As Long i, j, min, pickedRow
Dim As Long lb = Lbound(bs), ub = Ubound(bs)
Dim As Long decks(ub, ub)
Dim As Long count(ub)
Dim As Long sortedArr(ub)
For i = lb To ub
For j = lb To ub
If count(j) = 0 Or (count(j) > 0 And decks(j, count(j) - 1) >= bs(i)) Then
decks(j, count(j)) = bs(i)
count(j) += 1
Exit For
End If
Next
Next
min = decks(0, count(0) - 1)
pickedRow = 0
For i = lb To ub
For j = lb To ub
If count(j) > 0 And decks(j, count(j) - 1) < min Then
min = decks(j, count(j) - 1)
pickedRow = j
End If
Next
sortedArr(i) = min
count(pickedRow) -= 1
For j = lb To ub
If count(j) > 0 Then
min = decks(j, count(j) - 1)
pickedRow = j
Exit For
End If
Next
Next
For i = 0 To ub
bs(i) = sortedArr(i)
Next
End Sub
'--- Programa Principal ---
Dim As Long i
Dim As Long array(14) = {-5,-3, 0,-7, 5, 2, 3, 6,-6,-1, 1,-2, 4, 7,-4}
Dim As Long a = Lbound(array), b = Ubound(array)
Print "unsort ";
For i = a To b : Print Using "####"; array(i); : Next i
patienceSort(array())
Print !"\n sort ";
For i = a To b : Print Using "####"; array(i); : Next i
Sleep