OOBasic help me please I am desperate

Discuss the spreadsheet application
Post Reply
brandonmm1
Posts: 4
Joined: Mon Sep 19, 2016 6:05 am

OOBasic help me please I am desperate

Post by brandonmm1 »

Slide2.png
here is a run which includes at Row 2. This is an incomplete run because it includes Row 2. There is another incomplete run which lasts from Rows 21 to 23; this run is incomplete because it includes the last row of data, which is Row 23. There are two other runs in Example2: one run is in Rows 6-9 and the other is in Rows 12-16. Both of these runs are complete because none of them includes Row 2 or the last row of data.

Having defined the meaning of a complete run, we are now ready to tell you what your algorithm should do:

For each complete run in the data, your algorithm should output the row number of the beginning of the run, the row number of the end of the run and its run length. The run length of a complete run is the number of rows in the run.
Your algorithm should output the longest run length of all the complete runs in the data and the number of times the longest run length occurs in the data.
Slide3.png
Can anyone help me with the complete and incomplete run? I have tried to apply my idea over and over again but I keep on failing. I went to the consultation but it was of no help.... I hope someone can help me
OpenOffice 3.1 on Windows 10
jrkrideau
Volunteer
Posts: 3816
Joined: Sun Dec 30, 2007 10:00 pm
Location: Kingston Ontario Canada

Re: OOBasic help me please I am desperate

Post by jrkrideau »

I am a bit dubious with helping with homework but perhaps if you supply the actual data and perhaps a link to the actual question someone may help you. If you went to the consultation (Oz talk for Canaidian tutorial?) it shows effort.

I may just be slower than usual but I have no idea what you are doing here. Are you looking at data that looks like :

aa = aaaaaazzzzbbbbbbbjjj

and trying to determine the length of each run? What subject is this in?

To upload a file, there is an upload tab at the bottom of the Reply or Quote windows.
LibreOffice 7.3.7. 2; Ubuntu 22.04
User avatar
keme
Volunteer
Posts: 3704
Joined: Wed Nov 28, 2007 10:27 am
Location: Egersund, Norway

Re: OOBasic help me please I am desperate

Post by keme »

From your description I gather:
  • A "complete run" is a series of values above a given threshold, delimited by the existence of readings below the threshold before and after.
  • An "incomplete run" is a series of values above a given threshold, but there may be other (unknown) above-threshold readings before and/or after the known data.
Does this correctly describe the distinction of complete vs. incomplete runs?
Apache OO 4.1.12 and LibreOffice 7.5, mostly on Ms Windows 10
brandonmm1
Posts: 4
Joined: Mon Sep 19, 2016 6:05 am

Re: OOBasic help me please I am desperate

Post by brandonmm1 »

Yes, for the complete run you are true, the incomplete run is basically complete run but with first or last data included
OpenOffice 3.1 on Windows 10
User avatar
keme
Volunteer
Posts: 3704
Joined: Wed Nov 28, 2007 10:27 am
Location: Egersund, Norway

Re: OOBasic help me please I am desperate

Post by keme »

What is the idea you mentioned that you have tried to apply? (You could describe algorithm or general strategy, or supply program code.)
How did it fail? (Error message, wrong output, or no output at all?)

I guess a simple strategy description could be "stepping sequentially through data, conditionally incrementing or resetting counters with each step".
Apache OO 4.1.12 and LibreOffice 7.5, mostly on Ms Windows 10
brandonmm1
Posts: 4
Joined: Mon Sep 19, 2016 6:05 am

Re: OOBasic help me please I am desperate

Post by brandonmm1 »

my idea was basically, a data is considered valid for "starting data" if the data before it is less than threshold and the data itself is more than threshold. a data is considered valid for "ending data" if the data itself is more than threshold and the data after it is less than threshold. I have tried to apply it but i failed. maybe i input the wrong coding?
OpenOffice 3.1 on Windows 10
User avatar
keme
Volunteer
Posts: 3704
Joined: Wed Nov 28, 2007 10:27 am
Location: Egersund, Norway

Re: OOBasic help me please I am desperate

Post by keme »

Assuming that this is an assignment for procedural programming. (It is probably simpler to solve it using spreadsheet formulas.)

Perhaps consider this as a sequence of states, rather than comparing each item to the previous one.

Passing through data items, State RunStart is boolean, false until you have a reading below threshold, and after that it is always true. State Running is boolean, true when data item is above threshold, false otherwise.

Counter ThisRun is incremented when Running is true and reset when Running is false. Upon resetting ThisRun, first update value LongestRun if RunStart is true...

You get the logic? Important to do the assignments in correct order. You need a couple more counters and state variables.

Take into account the possibility that an incomplete run is equal to or longer than the longest complete run. What to do about that? Remember that there may be at most two incomplete runs, and only one of them may occur before the longest run.
Apache OO 4.1.12 and LibreOffice 7.5, mostly on Ms Windows 10
brandonmm1
Posts: 4
Joined: Mon Sep 19, 2016 6:05 am

Re: OOBasic help me please I am desperate

Post by brandonmm1 »

I get the point but I dont think we are allowed to use Run boolean etc. We havent been taught about that. Mainly we use while and if function
OpenOffice 3.1 on Windows 10
Post Reply