search highest digit in the array

search highest digit in the array

Postby Silvio.Falconi » Wed Mar 09, 2022 12:24 pm

I have this array

Image

How can I find the highest digit in the array?
example in this screen in the last line there is the value 663
the function should return me that in the combination (first column) the maximum output is 663 (9 column) and highlight it (bringing the cursor to that position)
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7062
Joined: Thu Oct 18, 2012 7:17 pm

Re: search highest digit in the array

Postby Detlef » Wed Mar 09, 2022 8:00 pm

Hi Silvio,
here a quick function to fnd the max value in your array.
Code: Select all  Expand view  RUN
FUNCTION aFindMax( xArray ) // xArray should be your array
LOCAL aVals := {;    //just for testing
                  { 0,  45,  29,  97, 472, 265, 127,   3, 123,  24,  11,  55 },;
                  { 0,  66, 104, 298,  79,  47,  12,  12,  90,  48, 130, 155 },;
                  { 0, 158,   7,   7,  95, 169,  86, 230, 148,  79, 446,  20 },;
                  { 0,  11,  17, 131, 422,  50, 204,  37,   5,  11,  48, 433 },;
                  { 0,  52,   6,  49, 312,  58, 128, 108, 284, 248,  92, 373 },;
                  { 0,  33,  30, 440, 451,  77,  60,  70, 227, 440,  31,  25 },;
                  { 0,  70, 134,   5,  60,  55,  11, 347,  22,  28, 549,  66 },;
                  { 0, 259,  58,  30,  18,  57,  91,  27, 126,  65,  78, 176 },;
                  { 0, 107,  42, 118,  94,  37,  49,  23, 623,  22,  19,  79 } ;
               }
LOCAL nRows := len( aVals )  
LOCAL nCols := len( aVals[1] )
LOCAL nR, nC
LOCAL nRmax := 0, nCmax := 0
LOCAL nMax  := 0

      for nR := 1 to nRows
         for nC := 2 to nCols
            if aVals[nR, nC] > nMax
               nMax := aVals[nR, nC]
               nRmax := nR
               nCmax := nC
            endif
         next
      next

      msginfo( nRmax ) //just for testing
      msginfo( nCmax ) //just for testing

RETURN ( { nRmax, nCmax } )    // Returns  array with row and col numbers of maximum
 

regards, Detlef
User avatar
Detlef
 
Posts: 209
Joined: Mon Feb 07, 2022 9:54 pm

Re: search highest digit in the array

Postby Silvio.Falconi » Thu Mar 10, 2022 8:06 am

Detlef wrote:Hi Silvio,
here a quick function to fnd the max value in your array.
Code: Select all  Expand view  RUN
FUNCTION aFindMax( xArray ) // xArray should be your array
LOCAL aVals := {;    //just for testing
                  { 0,  45,  29,  97, 472, 265, 127,   3, 123,  24,  11,  55 },;
                  { 0,  66, 104, 298,  79,  47,  12,  12,  90,  48, 130, 155 },;
                  { 0, 158,   7,   7,  95, 169,  86, 230, 148,  79, 446,  20 },;
                  { 0,  11,  17, 131, 422,  50, 204,  37,   5,  11,  48, 433 },;
                  { 0,  52,   6,  49, 312,  58, 128, 108, 284, 248,  92, 373 },;
                  { 0,  33,  30, 440, 451,  77,  60,  70, 227, 440,  31,  25 },;
                  { 0,  70, 134,   5,  60,  55,  11, 347,  22,  28, 549,  66 },;
                  { 0, 259,  58,  30,  18,  57,  91,  27, 126,  65,  78, 176 },;
                  { 0, 107,  42, 118,  94,  37,  49,  23, 623,  22,  19,  79 } ;
               }
LOCAL nRows := len( aVals )  
LOCAL nCols := len( aVals[1] )
LOCAL nR, nC
LOCAL nRmax := 0, nCmax := 0
LOCAL nMax  := 0

      for nR := 1 to nRows
         for nC := 2 to nCols
            if aVals[nR, nC] > nMax
               nMax := aVals[nR, nC]
               nRmax := nR
               nCmax := nC
            endif
         next
      next

      msginfo( nRmax ) //just for testing
      msginfo( nCmax ) //just for testing

RETURN ( { nRmax, nCmax } )    // Returns  array with row and col numbers of maximum
 

regards, Detlef


Run good

Image

thanks
Last edited by Silvio.Falconi on Thu Mar 10, 2022 8:28 am, edited 1 time in total.
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7062
Joined: Thu Oct 18, 2012 7:17 pm

Re: search highest digit in the array

Postby Detlef » Thu Mar 10, 2022 8:21 am

But one problem.
If there are two cells with the same highest value.
Then you must decide which cell is the one you want.
User avatar
Detlef
 
Posts: 209
Joined: Mon Feb 07, 2022 9:54 pm

Re: search highest digit in the array

Postby Silvio.Falconi » Thu Mar 10, 2022 8:31 am

Detlef wrote:But one problem.
If there are two cells with the same highest value.
Then you must decide which cell is the one you want.


I make statistical calculations on an archive of lottery extractions from 1939 to today ( here in Italy)
I made on 91 the first prg on clipper 87 and now I rewrite the prg with fwh with many problems

On Picture I perform the calculation of the tens for what concerns the Terni (ie the output of 3 numbers), these are classical groupings

Detlef,
for the same value it is a problem, I don't know how to do it and anyway I think it always takes the last calculated?

I made
nRowSelect:=Colorize_Max(oBrw,RGB( 255, 0,0 ),RGB( 252, 235, 220 ))
oBrw:KeyNo:= nRowSelect

static Function Colorize_Max(oBrw,nColor1,nColor2)
local avals:= oBrw:aArraydata
local atest:= aFindMax( aVals )
local nRow:= atest[1]
local nCol:= atest[2]
oBrw:aCols[nCol]:bClrStd := {|| { CLR_BLACK,IIf(oBrw:nArrayAt=nRow, nColor1,nColor2) } }
return nRow

any suggestion ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7062
Joined: Thu Oct 18, 2012 7:17 pm

Re: search highest digit in the array

Postby Detlef » Thu Mar 10, 2022 9:53 am

Silvio,

if you want to have the last of same values you must change only one line of my function.

if aVals[nR, nC] >= nMax // instead of only "="
User avatar
Detlef
 
Posts: 209
Joined: Mon Feb 07, 2022 9:54 pm

Re: search highest digit in the array

Postby Marc Venken » Thu Mar 10, 2022 12:04 pm

Silvio,

Just curious, Did it make any difference in playing lotto with a statistical program ? I hope for you....
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1434
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: search highest digit in the array

Postby Silvio.Falconi » Thu Mar 10, 2022 5:27 pm

Marc Venken wrote:Silvio,

Just curious, Did it make any difference in playing lotto with a statistical program ? I hope for you....


help me sometimes
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7062
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], Silvio.Falconi and 110 guests