I would create a matrix A[i,j] with i = 1,2,3,...31 (31 rows) and
j=1,2,3,...20 (20 columns).
Initialize the matrix to all zeroes.
Then for each day of the month, if the number "k" occurs in day j, then
set A[j,k] := 1.
At the end of the month, the sum of the elements in row k will tell you
how many times k occurred during the month.
Then scan each row of the matrix looking for three or more consecutive
1's (left as an exercise :-)
On 3/9/2013 10:00 AM, Howard Page-Clark wrote:
On 09/03/13 3:06, appjaws wrote:
I have a series of results, for each day of the month I have 10
numbers
ranging from 1 to 20. i.e.
Day1 1,3,4,5,7,9,12,16,17,20
Day2 3,4,5,6,8,9,15,17,18,19
...
I just realised that I need to sort the numbers because they are not
like my example above. So where and how would I sort the array for each
Day and then call ThreeOrMore?
If you have any programming books you'll almost certainly find they
include a chapter on sorting algorithms (bubble sort, quicksort etc.).
One FPC/Lazarus tutorial implementation is at
http://www.pp4s.co.uk/main/tu-ss-sort-quick-demo1a.html
and Lazarus also has several integer quicksort implementations in its
own code such as at ...\lazarus\lcl\grids.pas, line 2850
Howard
--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus