found the same number on an array

found the same number on an array

Postby Silvio.Falconi » Tue May 17, 2022 6:18 pm

I have a big array

Code: Select all  Expand view
aadd(aTab      ,{ r[1],;
                         r[2],;
                         r[3],;
                         r[4],;
                         r[5],;
                         r[6],;
                         r[7],;
                         r[8],;
                         r[9],;
                         r[10],;
                         r[11],;
                         r[12],;
                         r[13],;
                         r[14],;
                         r[15],;
                         r[16],;
                         r[17],;
                         r[18],;
                         r[19],;
                         r[20],;
                         r[21],;
                         r[22],;
                         r[23],;
                         r[24],;
                         r[25],;
                         r[26],;
                         r[27],;
                         r[28],;
                         r[29],;
                         r[30],;
                         r[31],;
                         r[32],;
                         r[33],;
                         r[34],;
                         r[35],;
                         r[36],;
                         r[37],;
                         r[38],;
                         r[39],;
                         r[40],;
                         r[41],;
                         r[42],;
                         r[43],;
                         r[44],;
                         r[45],;
                         r[46],;
                         r[47],;
                         r[48],;
                         r[49],;
                         r[50],;
                         r[51],;
                         r[52],;
                         r[53],;
                         r[54],;
                         r[55],;
                         r[56]})
 



I have to check if a number is equal from field r[2] to field r[6] in the array aTab
but this applies to the first wheel
each block has 5 numbers

sample

Code: Select all  Expand view
If ba="S"
         nRuota:=1
         r[2]:=  ck(ba1,aTab,nruota)
         r[3]:=  ck(ba2,aTab,nruota)
         r[4]:=  ck(ba3,aTab,nruota)
         r[5]:=  ck(ba4,aTab,nruota)
         r[6]:=  ck(ba5,aTab,nruota)
        Endif


I made this check function but it seems run bad

Code: Select all  Expand view
Function ck(num,atab,nruota)
   local nrow
   local k1,k2,k3,k4,k5
   local cond
   local nNumber
   local ltrovato:=.f.

 IF len(atab)>0
   For nrow= 1 to len(atab)
      IF AScan( atab[ nrow ], { | n | n != num }, 2, 6 ) == 0
             nNumber:= 0
            else
             nNumber:= num
          ENDIF
    next
  ELSE
    nNumber:= num
   ENDIF
  return nNumber




sample


Image

the numbers with red circle not must be showed but replaced with zero because they went out in the previous draws

How I can resolve it ?
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: 6768
Joined: Thu Oct 18, 2012 7:17 pm

Re: found the same number on an array

Postby Silvio.Falconi » Tue May 17, 2022 8:40 pm

i tried also with




Code: Select all  Expand view


Function ck(num,atab,nruota)
   local nNumber
   local nRows := len( atab )
   local nR, nC
   local nEnd
   local nInit
   do case
      case nruota =1    //ba
         nInit:= 2
         nEnd:= 6
      case nruota =2   //ca
         nInit:= 7
         nEnd:= 11
      Endcase

   If len(atab)>0
            for nR := 1 to nRows
               for nC := nInit to nEnd    //cols
                   if atab[nR, nC] = num
                       nNumber:= 0
                      else
                       nNumber:= num
                    endif
                  next
               next
           ELSE
    nNumber:= num
   ENDIF
  return nNumber



 


why not run ok ?
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: 6768
Joined: Thu Oct 18, 2012 7:17 pm

Re: found the same number on an array

Postby Jimmy » Wed May 18, 2022 12:47 am

hi Silvo.

need some Data to build a Sample.
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1585
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: found the same number on an array

Postby Silvio.Falconi » Wed May 18, 2022 9:43 am

Jimmy wrote:hi Silvo.

need some Data to build a Sample.


test sample and archive on your mail
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: 6768
Joined: Thu Oct 18, 2012 7:17 pm

Re: found the same number on an array

Postby Otto » Wed May 18, 2022 10:11 am

Hello Silvio,
Did you send it to Max too?

Best regards,
Otto

PS: By the way - MAX is a metaphor.
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6005
Joined: Fri Oct 07, 2005 7:07 pm

Re: found the same number on an array

Postby Silvio.Falconi » Wed May 18, 2022 11:14 am

Otto wrote:Hello Silvio,
Did you send it to Max too?

Best regards,
Otto

PS: By the way - MAX is a metaphor.



I honestly don't understand your metaphor, is it an Austrian metaphor?
My brother Max doesn't understand anything about computers and is a lawyer and lives in Florence
do I have to send it to him too? why ? Since when have you known my brother Max?

>mod harbour - Vamos a la conquista de la Web
Tell me when you conquer the web that I have the sparkling wine ready in the fridge and let's drink it !!!
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: 6768
Joined: Thu Oct 18, 2012 7:17 pm

Re: found the same number on an array

Postby Silvio.Falconi » Wed May 18, 2022 8:58 pm

I made a small test
Code: Select all  Expand view

# include "fivewin.ch"

Function test()

local nRit,n1,n2,n3,n4,n5

LOCAL atab := {{ 0,  16,  31,   30, 50,  81 },;
               { 1,  47,  44,   62,  8,  86 },;
               { 2,  51,  26,   88,  69, 60 },;
               { 3,  49,  77,   90,  85, 14 },;
               { 4,  34,  82,   52,  53, 45 } }


nRit= 5
n1:= SearchNumber(67,atab)
n2:= SearchNumber(48,atab)
n3:= SearchNumber(16,atab)
n4:= SearchNumber(42,atab)
n5:= SearchNumber(87,atab)

aadd(atab,{nrit,n1,n2,n3,n4,n5})

nRit:= 6
n1:= SearchNumber(89,atab)
n2:= SearchNumber(69,atab)
n3:= SearchNumber(84,atab)
n4:= SearchNumber(73,atab)
n5:= SearchNumber(50,atab)

aadd(atab,{nrit,n1,n2,n3,n4,n5})

nRit:= 7
n1:= SearchNumber(47,atab)
n2:= SearchNumber(15,atab)
n3:= SearchNumber(76,atab)
n4:= SearchNumber(12,atab)
n5:= SearchNumber(90,atab)

aadd(atab,{nrit,n1,n2,n3,n4,n5})

xbrowser atab
return nil




Function SearchNumber(num,aVals)

    LOCAL nRows := len( aVals )
    LOCAL nR, nC
    local nMax:= num
    local nCMax:=99
    local nNumber

       for nR := 1 to nRows
             for nC := 2 to 6
                if aVals[nR, nC] = nMax
                 nCmax := 0
                endif
             next
          next

          If nCMax= 99
            nNumber := num
           else
            nNumber := nCMax
          endif
return nNumber
 


the function searcnumber perhaps run ok ..


Image


Question
I can't do this to infinity but until all numbers from 1 to 90 have come out in all columns (for each column from col 2 to 56)
how can I now calculate if all 90 numbers have come out in each column?
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: 6768
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: W3C [Validator] and 95 guests