We would like to build a community for Small Basic programmers of any age who like to code. Everyone from total beginner to guru is welcome. Click here to register and share your programming journey!


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Challenge 9 - Quick sort
#11
(10-28-2024, 06:38 PM)jrmrhrb00 Wrote: AB, L-S,

I went back to basically the same code.

JR

Is this code your last code?
Code:
'small basic array
For i = 1 To 10
  name[i]=math.GetRandomNumber(10)
EndFor

'creates ldArray from indices
status=LDArray.CreateFromIndices(name)
TextWindow.WriteLine(status)

'loads ldarray with random numbers
For i = 1 To 10
  status[i]=Math.GetRandomNumber(10)
EndFor

'why does the below fail
result=LDArray.Sort(status)
TextWindow.WriteLine(result)

'would give a listing of sorted numbers, but just shows them in their random order
For i = 1 To 10
  TextWindow.WriteLine(status[i])
  endfor
Reply
#12
AB,

Yes. The same code. For the LDArray.sort status is supposed to be a LDArray, but that fails. Maybe it's a code bug in theLitDev extension.

JR
Reply
#13
(10-28-2024, 07:06 PM)jrmrhrb00 Wrote: AB,

Yes. The same code. For the LDArray.sort status is supposed to be a LDArray, but that fails. Maybe it's a code bug in theLitDev extension.

JR

But in this code, line status[i]=Math.GetRandomNumber(10) is incorrect.

There should be line LDArray.SetValue(status, i, Math.GetRandomNumber(10)) instead.
Reply
#14
AB,

I put that in and it makes no difference. The program runs the same.

'small basic array
For i = 1 To 10
  name[i]=math.GetRandomNumber(10)
  LDArray.SetValue(status, i, Math.GetRandomNumber(10))
EndFor

The above code is the way that you generate a small basic array which is what this is supposed to do. I know this works. Yours works too, but it didn't fix anything.
Reply
#15
(10-28-2024, 07:27 PM)jrmrhrb00 Wrote: AB,

I put that in and it makes no difference. The program runs the same.

'small basic array
For i = 1 To 10
  name[i]=math.GetRandomNumber(10)
  LDArray.SetValue(status, i, Math.GetRandomNumber(10))
EndFor

The above code is the way that you generate a small basic array which is what this is supposed to do. I know this works. Yours works too, but it didn't fix anything.

JR,

This is because we haven't fixed all the bugs yet.
Please tell us WHAT exactly you want to get as a result of the program work?  Shy
Reply
#16
AB,

This got started because of the LitDev challenge. Then I used the LDArray.sort option and can't get it to work.

JR
Reply
#17
(10-28-2024, 07:45 PM)jrmrhrb00 Wrote: AB,

This got started because of the LitDev challenge. Then I used the LDArray.sort option and can't get it to work.

JR

JR,

I see.
In this case, your algorithm of actions should be approximately as follows:
  1. create an empty LDArray (for example, “status”);
  2. fill this empty array with random numbers;
  3. perform sorting of the filled array using the LDArray.Sort() method.
Do you agree?

AB
Reply
#18
AB,

Yes. That's the way it should work.

JR
Reply
#19
(10-28-2024, 08:36 PM)jrmrhrb00 Wrote: AB,

Yes. That's the way it should work.

JR

JR,

Okay.
But, in your code, you have NOT CREATED an empty LDArray, but are already trying to fill it with random numbers.

Missing line: status = LDArray.Create(10)

AB
Reply
#20
AB,

This is what creates the LDArray

'creates ldArray from indices
status=LDArray.CreateFromIndices(name)
TextWindow.WriteLine(status)

Status even shows you Array1.

JR
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)