delete identical records

delete identical records

Postby Silvio.Falconi » Mon Oct 31, 2022 4:29 pm

By creating an array with three for next loops I have to delete the records where I find equal numbers in the three columns

Code: Select all  Expand view
for h=1 to Len(atmp)
        If  atmp[h][1] == atmp[h][2]  .or. ;
            atmp[h][1] == atmp[h][3]  .or.  ;
            atmp[h][3] == atmp[h][2]
               HB_ADel( aTmp, h, .t. )
            Endif
         next


but then it happens that I have two records (A and B)

Image Image

which have an equal number in the first or second column because the triplet

1- 2 - 88

is the same as the triplet

2 - 1 - 88

and

1- 88 -2

how can i solve to find the same records?
I tried using aScan But I couldn't


I tried also with

Code: Select all  Expand view
for h=1 to Len(atmp)
        If  atmp[h][1] == atmp[h][2]  .or. ;
            atmp[h][1] == atmp[h][3]  .or.  ;
            atmp[h][3] == atmp[h][2]
               HB_ADel( aTmp, h, .t. )
            Endif
         next

        nVolte := 0

         For t= 1 to Len(aTmp)
            nA:= atmp[t][1]
            nb:= atmp[t][2]
            nc:= atmp[t][3]
                  for h=1 to Len(atmp)
                      If  atmp[h][1] == nA  .and. ;
                            atmp[h][2] == nB .and.  ;
                             atmp[h][3] ==nC
                         nVolte++
                       If  nVolte >1
                          HB_ADel( aTmp, h, .t. )
                          Endif
                   Endif
                next
             next
 


but 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: 6849
Joined: Thu Oct 18, 2012 7:17 pm

Re: delete identical records

Postby Cgallegoa » Tue Nov 01, 2022 8:03 pm

Silvio:

Code: Select all  Expand view
#include "FiveWin.ch"

PROCEDURE Main()
    LOCAL h, h2, aReg, aTmp2, nIdx, aRes := {.F.,.F.,.F.}
    LOCAL aTmp := {{1,84,6},{1,85,5},{1,86,4},{1,87,3},{1,88,2},{2,1,88},{2,3,86},{2,4,85},;
                   {2,5,84},{1,2,88},{2,6,83},{2,7,82},{2,8,81},{2,9,80},{2,10,79}}
   
    xBrowse(aTmp, "before...")
   
    FOR EACH aReg in aTmp
        nIdx := HB_EnumIndex()
        for h := 1 TO LEN(aTmp)
            if h <> nIdx
               aRes := {.F.,.F.,.F.}
               FOR h2:=1 TO LEN(aReg)
                   aTmp2 := aTmp[h]
                   nPos := ASCAN(aTmp2,{|x| x = aReg[h2] })
                   if nPos <> 0
                      aRes[h2] := .T.          
                   endif
               next
               if aRes[1] .AND. aRes[2] .AND. aRes[3]
                                ADel(aTmp, nIdx , .T. )
               endif
            endif
        next
    NEXT
   
    xBrowse(aTmp, "after...")

RETURN
 

Regards,
Saludos,

Carlos Gallego

*** FWH-23.10, xHarbour 1.2.3 Build 20190603, Borland C++7.30, PellesC ***
Cgallegoa
 
Posts: 425
Joined: Sun Oct 16, 2005 3:32 am
Location: Quito - Ecuador

Re: delete identical records

Postby Silvio.Falconi » Tue Nov 01, 2022 10:48 pm

Cgallegoa wrote:Silvio:

Code: Select all  Expand view
#include "FiveWin.ch"

PROCEDURE Main()
    LOCAL h, h2, aReg, aTmp2, nIdx, aRes := {.F.,.F.,.F.}
    LOCAL aTmp := {{1,84,6},{1,85,5},{1,86,4},{1,87,3},{1,88,2},{2,1,88},{2,3,86},{2,4,85},;
                   {2,5,84},{1,2,88},{2,6,83},{2,7,82},{2,8,81},{2,9,80},{2,10,79}}
   
    xBrowse(aTmp, "before...")
   
    FOR EACH aReg in aTmp
        nIdx := HB_EnumIndex()
        for h := 1 TO LEN(aTmp)
            if h <> nIdx
               aRes := {.F.,.F.,.F.}
               FOR h2:=1 TO LEN(aReg)
                   aTmp2 := aTmp[h]
                   nPos := ASCAN(aTmp2,{|x| x = aReg[h2] })
                   if nPos <> 0
                      aRes[h2] := .T.          
                   endif
               next
               if aRes[1] .AND. aRes[2] .AND. aRes[3]
                                ADel(aTmp, nIdx , .T. )
               endif
            endif
        next
    NEXT
   
    xBrowse(aTmp, "after...")

RETURN
 

Regards,


your test run but
when I put it on my source it crashout


Code: Select all  Expand view
#include "FiveWin.ch"

PROCEDURE Main()
    LOCAL h, h2, aReg:= {}, aTmp2, nIdx, aRes := {.F.,.F.,.F.}
    LOCAL aTmp:=  {{ 0,0,0}}


    //:= {{1,84,6},{1,85,5},{1,86,4},{1,87,3},{1,88,2},{2,1,88},{2,3,86},{2,4,85},;
               //    {2,5,84},{1,2,88},{2,6,83},{2,7,82},{2,8,81},{2,9,80},{2,10,79}}
   

    local ntotale
    local nValore:= 1
    local nTipo := 1

       For n= 1 to 90
         For k= 1 to 90
            For j= 1 to 90
              nTotale  :=   Calcolo_3_numeri(n,k,j,ntipo)
              If  nTotale=nvalore
                       aadd(aTmp,{n,k,j})
                  Endif
            next
         next
      next

      xBrowse(aTmp, "before...")








    FOR EACH aReg in aTmp
        nIdx := HB_EnumIndex()
        for h := 1 TO LEN(aTmp)
            if h <> nIdx
               aRes := {.F.,.F.,.F.}
               FOR h2:=1 TO LEN(aReg)
                   aTmp2 := aTmp[h]
                   nPos := ASCAN(aTmp2,{|x| x = aReg[h2] })
                   if nPos <> 0
                      aRes[h2] := .T.
                   endif
               next
               if aRes[1] .AND. aRes[2] .AND. aRes[3]
                                ADel(aTmp, nIdx , .T. )
               endif
            endif
        next
    NEXT

    xBrowse(aTmp, "after...")

    RETURN



   Function Calcolo_3_numeri(n1,n2,n3,nTipo)

   local nNum:=0
   local nTemp:=0
   Do case
      case nTipo= 1 // suma ciclométrica      ok
          nTemp:= n1+n2+n3
          If nTemp > 90
            nTemp:= ntemp-90      //el exterior 90
          Endif
       case nTipo= 2 //distancia ciclométrica    ok
            if n1>n2
               if n1>n3
                  nTemp:= n1-n2-n3
               else
                  nTemp:= n3-n1-n2
               endif
           else
              if n2>n3
                 nTemp:= n2-n1-n3
              else
                nTemp:= n3-n1-n2
             endif
           endif
          If nTemp > 45          //   el exterior 45
             nTemp:= 90-nTemp
          Endif
       Case nTipo= 3  //suma matemática        ok
          nTemp:= n1+n2+n3

       case ntipo = 4 // distancia matemática     ok
          if n1>n2
               if n1>n3
                  nTemp:= n1-n2-n3
               else
                  nTemp:= n3-n1-n2
               endif
           else
              if n2>n3
                 nTemp:= n2-n1-n3
              else
                nTemp:= n3-n1-n2
             endif
           endif

     Endcase
     nNum := ntemp
     return nNum




 


crash on line 41

Error description: Error BASE/1132 Bound error: array access
Args:
[ 1] = A {{0,0,0},{1,89,1},{2,3,86},{3,1,87},{4,1,86},{4,4,83},{5,1,85},{5,4,82},{6,1,84},{6,4,81},{6,7 ... } length: 748
[ 2] = N 749
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: 6849
Joined: Thu Oct 18, 2012 7:17 pm

Re: delete identical records

Postby Cgallegoa » Wed Nov 02, 2022 12:04 am

Silvio:

Code: Select all  Expand view
#include "FiveWin.ch"

PROCEDURE Main()
    LOCAL h, h2, aReg:= {}, aTmp2, nIdx, aRes := {.F.,.F.,.F.}
    LOCAL aTmp:=  {{ 0,0,0}}

    LOCAL aTmp3

    //:= {{1,84,6},{1,85,5},{1,86,4},{1,87,3},{1,88,2},{2,1,88},{2,3,86},{2,4,85},;
               //    {2,5,84},{1,2,88},{2,6,83},{2,7,82},{2,8,81},{2,9,80},{2,10,79}}

    local ntotale
    local nValore:= 1
    local nTipo := 1

    For n= 1 to 90
        For k= 1 to 90
            For j= 1 to 90
                nTotale  :=   Calcolo_3_numeri(n,k,j,ntipo)
                If nTotale=nvalore
                   aadd(aTmp,{n,k,j})
                Endif
            next
        next
    next

    xBrowse(aTmp, "before... Len: " + cStr(Len(aTmp)) )

    aTmp3 := ACLONE(aTmp)     // ***** AAD this line ***** //

    FOR EACH aReg in aTmp
        nIdx := HB_EnumIndex()
        for h := 1 TO LEN(aTmp3)
            if h <> nIdx
               aRes := {.F.,.F.,.F.}
               FOR h2:=1 TO LEN(aReg)
                   aTmp2 := aTmp[h]
                   nPos := ASCAN(aTmp2,{|x| x = aReg[h2] })
                   if nPos <> 0
                      aRes[h2] := .T.          
                   endif
               next
               if aRes[1] .AND. aRes[2] .AND. aRes[3]
                                ADel(aTmp3, nIdx , .T. )
               endif
            endif
        next
    NEXT

    xBrowse(aTmp3, "after...Len: " + cStr(Len(aTmp3)))

RETURN(aTmp3)
//------------------------------------------------------------------------//

Function Calcolo_3_numeri(n1,n2,n3,nTipo)

   local nNum:=0
   local nTemp:=0
   Do case
      case nTipo= 1 // suma ciclométrica      ok
          nTemp:= n1+n2+n3
          If nTemp > 90
            nTemp:= ntemp-90      //el exterior 90
          Endif
       case nTipo= 2 //distancia ciclométrica    ok
            if n1>n2
               if n1>n3
                  nTemp:= n1-n2-n3
               else
                  nTemp:= n3-n1-n2
               endif
           else
              if n2>n3
                 nTemp:= n2-n1-n3
              else
                nTemp:= n3-n1-n2
             endif
           endif
          If nTemp > 45          //   el exterior 45
             nTemp:= 90-nTemp
          Endif
       Case nTipo= 3  //suma matemática        ok
          nTemp:= n1+n2+n3

       case ntipo = 4 // distancia matemática     ok
          if n1>n2
               if n1>n3
                  nTemp:= n1-n2-n3
               else
                  nTemp:= n3-n1-n2
               endif
           else
              if n2>n3
                 nTemp:= n2-n1-n3
              else
                nTemp:= n3-n1-n2
             endif
           endif

     Endcase
     nNum := ntemp
return nNum
 
Saludos,

Carlos Gallego

*** FWH-23.10, xHarbour 1.2.3 Build 20190603, Borland C++7.30, PellesC ***
Cgallegoa
 
Posts: 425
Joined: Sun Oct 16, 2005 3:32 am
Location: Quito - Ecuador

Re: delete identical records

Postby Silvio.Falconi » Wed Nov 02, 2022 8:32 am

Cgallegoa wrote:Silvio:

Code: Select all  Expand view
#include "FiveWin.ch"

PROCEDURE Main()
    LOCAL h, h2, aReg:= {}, aTmp2, nIdx, aRes := {.F.,.F.,.F.}
    LOCAL aTmp:=  {{ 0,0,0}}

    LOCAL aTmp3

    //:= {{1,84,6},{1,85,5},{1,86,4},{1,87,3},{1,88,2},{2,1,88},{2,3,86},{2,4,85},;
               //    {2,5,84},{1,2,88},{2,6,83},{2,7,82},{2,8,81},{2,9,80},{2,10,79}}

    local ntotale
    local nValore:= 1
    local nTipo := 1

    For n= 1 to 90
        For k= 1 to 90
            For j= 1 to 90
                nTotale  :=   Calcolo_3_numeri(n,k,j,ntipo)
                If nTotale=nvalore
                   aadd(aTmp,{n,k,j})
                Endif
            next
        next
    next

    xBrowse(aTmp, "before... Len: " + cStr(Len(aTmp)) )

    aTmp3 := ACLONE(aTmp)     // ***** AAD this line ***** //

    FOR EACH aReg in aTmp
        nIdx := HB_EnumIndex()
        for h := 1 TO LEN(aTmp3)
            if h <> nIdx
               aRes := {.F.,.F.,.F.}
               FOR h2:=1 TO LEN(aReg)
                   aTmp2 := aTmp[h]
                   nPos := ASCAN(aTmp2,{|x| x = aReg[h2] })
                   if nPos <> 0
                      aRes[h2] := .T.          
                   endif
               next
               if aRes[1] .AND. aRes[2] .AND. aRes[3]
                                ADel(aTmp3, nIdx , .T. )
               endif
            endif
        next
    NEXT

    xBrowse(aTmp3, "after...Len: " + cStr(Len(aTmp3)))

RETURN(aTmp3)
//------------------------------------------------------------------------//

Function Calcolo_3_numeri(n1,n2,n3,nTipo)

   local nNum:=0
   local nTemp:=0
   Do case
      case nTipo= 1 // suma ciclométrica      ok
          nTemp:= n1+n2+n3
          If nTemp > 90
            nTemp:= ntemp-90      //el exterior 90
          Endif
       case nTipo= 2 //distancia ciclométrica    ok
            if n1>n2
               if n1>n3
                  nTemp:= n1-n2-n3
               else
                  nTemp:= n3-n1-n2
               endif
           else
              if n2>n3
                 nTemp:= n2-n1-n3
              else
                nTemp:= n3-n1-n2
             endif
           endif
          If nTemp > 45          //   el exterior 45
             nTemp:= 90-nTemp
          Endif
       Case nTipo= 3  //suma matemática        ok
          nTemp:= n1+n2+n3

       case ntipo = 4 // distancia matemática     ok
          if n1>n2
               if n1>n3
                  nTemp:= n1-n2-n3
               else
                  nTemp:= n3-n1-n2
               endif
           else
              if n2>n3
                 nTemp:= n2-n1-n3
              else
                nTemp:= n3-n1-n2
             endif
           endif

     Endcase
     nNum := ntemp
return nNum
 


Now run but the array must be of 1305 lines (3 columns) as this
with   local nValore:= 1
    local nTipo := 1

Code: Select all  Expand view

1   2   88
1   3   87
1   4   86
1   5   85
1   6   84
1   7   83
1   8   82
1   9   81
1   10  80
1   11  79
1   12  78
1   13  77
1   14  76
1   15  75
1   16  74
1   17  73
1   18  72
1   19  71
1   20  70
1   21  69
1   22  68
1   23  67
1   24  66
1   25  65
1   26  64
1   27  63
1   28  62
1   29  61
1   30  60
1   31  59
1   32  58
1   33  57
1   34  56
1   35  55
1   36  54
1   37  53
1   38  52
1   39  51
1   40  50
1   41  49
1   42  48
1   43  47
1   44  46
2   3   86
2   4   85
2   5   84
2   6   83
2   7   82
2   8   81
2   9   80
2   10  79
2   11  78
2   12  77
2   13  76
2   14  75
2   15  74
2   16  73
2   17  72
2   18  71
2   19  70
2   20  69
2   21  68
2   22  67
2   23  66
2   24  65
2   25  64
2   26  63
2   27  62
2   28  61
2   29  60
2   30  59
2   31  58
2   32  57
2   33  56
2   34  55
2   35  54
2   36  53
2   37  52
2   38  51
2   39  50
2   40  49
2   41  48
2   42  47
2   43  46
2   44  45
2   89  90
3   4   84
3   5   83
3   6   82
3   7   81
3   8   80
3   9   79
3   10  78
3   11  77
3   12  76
3   13  75
3   14  74
3   15  73
3   16  72
3   17  71
3   18  70
3   19  69
3   20  68
3   21  67
3   22  66
3   23  65
3   24  64
3   25  63
3   26  62
3   27  61
3   28  60
3   29  59
3   30  58
3   31  57
3   32  56
3   33  55
3   34  54
3   35  53
3   36  52
3   37  51
3   38  50
3   39  49
3   40  48
3   41  47
3   42  46
3   43  45
3   88  90
4   5   82
4   6   81
4   7   80
4   8   79
4   9   78
4   10  77
4   11  76
4   12  75
4   13  74
4   14  73
4   15  72
4   16  71
4   17  70
4   18  69
4   19  68
4   20  67
4   21  66
4   22  65
4   23  64
4   24  63
4   25  62
4   26  61
4   27  60
4   28  59
4   29  58
4   30  57
4   31  56
4   32  55
4   33  54
4   34  53
4   35  52
4   36  51
4   37  50
4   38  49
4   39  48
4   40  47
4   41  46
4   42  45
4   43  44
4   87  90
4   88  89
5   6   80
5   7   79
5   8   78
5   9   77
5   10  76
5   11  75
5   12  74
5   13  73
5   14  72
5   15  71
5   16  70
5   17  69
5   18  68
5   19  67
5   20  66
5   21  65
5   22  64
5   23  63
5   24  62
5   25  61
5   26  60
5   27  59
5   28  58
5   29  57
5   30  56
5   31  55
5   32  54
5   33  53
5   34  52
5   35  51
5   36  50
5   37  49
5   38  48
5   39  47
5   40  46
5   41  45
5   42  44
5   86  90
5   87  89
6   7   78
6   8   77
6   9   76
6   10  75
6   11  74
6   12  73
6   13  72
6   14  71
6   15  70
6   16  69
6   17  68
6   18  67
6   19  66
6   20  65
6   21  64
6   22  63
6   23  62
6   24  61
6   25  60
6   26  59
6   27  58
6   28  57
6   29  56
6   30  55
6   31  54
6   32  53
6   33  52
6   34  51
6   35  50
6   36  49
6   37  48
6   38  47
6   39  46
6   40  45
6   41  44
6   42  43
6   85  90
6   86  89
6   87  88
7   8   76
7   9   75
7   10  74
7   11  73
7   12  72
7   13  71
7   14  70
7   15  69
7   16  68
7   17  67
7   18  66
7   19  65
7   20  64
7   21  63
7   22  62
7   23  61
7   24  60
7   25  59
7   26  58
7   27  57
7   28  56
7   29  55
7   30  54
7   31  53
7   32  52
7   33  51
7   34  50
7   35  49
7   36  48
7   37  47
7   38  46
7   39  45
7   40  44
7   41  43
7   84  90
7   85  89
7   86  88
8   9   74
8   10  73
8   11  72
8   12  71
8   13  70
8   14  69
8   15  68
8   16  67
8   17  66
8   18  65
8   19  64
8   20  63
8   21  62
8   22  61
8   23  60
8   24  59
8   25  58
8   26  57
8   27  56
8   28  55
8   29  54
8   30  53
8   31  52
8   32  51
8   33  50
8   34  49
8   35  48
8   36  47
8   37  46
8   38  45
8   39  44
8   40  43
8   41  42
8   83  90
8   84  89
8   85  88
8   86  87
9   10  72
9   11  71
9   12  70
9   13  69
9   14  68
9   15  67
9   16  66
9   17  65
9   18  64
9   19  63
9   20  62
9   21  61
9   22  60
9   23  59
9   24  58
9   25  57
9   26  56
9   27  55
9   28  54
9   29  53
9   30  52
9   31  51
9   32  50
9   33  49
9   34  48
9   35  47
9   36  46
9   37  45
9   38  44
9   39  43
9   40  42
9   82  90
9   83  89
9   84  88
9   85  87
10  11  70
10  12  69
10  13  68
10  14  67
10  15  66
10  16  65
10  17  64
10  18  63
10  19  62
10  20  61
10  21  60
10  22  59
10  23  58
10  24  57
10  25  56
10  26  55
10  27  54
10  28  53
10  29  52
10  30  51
10  31  50
10  32  49
10  33  48
10  34  47
10  35  46
10  36  45
10  37  44
10  38  43
10  39  42
10  40  41
10  81  90
10  82  89
10  83  88
10  84  87
10  85  86
11  12  68
11  13  67
11  14  66
11  15  65
11  16  64
11  17  63
11  18  62
11  19  61
11  20  60
11  21  59
11  22  58
11  23  57
11  24  56
11  25  55
11  26  54
11  27  53
11  28  52
11  29  51
11  30  50
11  31  49
11  32  48
11  33  47
11  34  46
11  35  45
11  36  44
11  37  43
11  38  42
11  39  41
11  80  90
11  81  89
11  82  88
11  83  87
11  84  86
12  13  66
12  14  65
12  15  64
12  16  63
12  17  62
12  18  61
12  19  60
12  20  59
12  21  58
12  22  57
12  23  56
12  24  55
12  25  54
12  26  53
12  27  52
12  28  51
12  29  50
12  30  49
12  31  48
12  32  47
12  33  46
12  34  45
12  35  44
12  36  43
12  37  42
12  38  41
12  39  40
12  79  90
12  80  89
12  81  88
12  82  87
12  83  86
12  84  85
13  14  64
13  15  63
13  16  62
13  17  61
13  18  60
13  19  59
13  20  58
13  21  57
13  22  56
13  23  55
13  24  54
13  25  53
13  26  52
13  27  51
13  28  50
13  29  49
13  30  48
13  31  47
13  32  46
13  33  45
13  34  44
13  35  43
13  36  42
13  37  41
13  38  40
13  78  90
13  79  89
13  80  88
13  81  87
13  82  86
13  83  85
14  15  62
14  16  61
14  17  60
14  18  59
14  19  58
14  20  57
14  21  56
14  22  55
14  23  54
14  24  53
14  25  52
14  26  51
14  27  50
14  28  49
14  29  48
14  30  47
14  31  46
14  32  45
14  33  44
14  34  43
14  35  42
14  36  41
14  37  40
14  38  39
14  77  90
14  78  89
14  79  88
14  80  87
14  81  86
14  82  85
14  83  84
15  16  60
15  17  59
15  18  58
15  19  57
15  20  56
15  21  55
15  22  54
15  23  53
15  24  52
15  25  51
15  26  50
15  27  49
15  28  48
15  29  47
15  30  46
15  31  45
15  32  44
15  33  43
15  34  42
15  35  41
15  36  40
15  37  39
15  76  90
15  77  89
15  78  88
15  79  87
15  80  86
15  81  85
15  82  84
16  17  58
16  18  57
16  19  56
16  20  55
16  21  54
16  22  53
16  23  52
16  24  51
16  25  50
16  26  49
16  27  48
16  28  47
16  29  46
16  30  45
16  31  44
16  32  43
16  33  42
16  34  41
16  35  40
16  36  39
16  37  38
16  75  90
16  76  89
16  77  88
16  78  87
16  79  86
16  80  85
16  81  84
16  82  83
17  18  56
17  19  55
17  20  54
17  21  53
17  22  52
17  23  51
17  24  50
17  25  49
17  26  48
17  27  47
17  28  46
17  29  45
17  30  44
17  31  43
17  32  42
17  33  41
17  34  40
17  35  39
17  36  38
17  74  90
17  75  89
17  76  88
17  77  87
17  78  86
17  79  85
17  80  84
17  81  83
18  19  54
18  20  53
18  21  52
18  22  51
18  23  50
18  24  49
18  25  48
18  26  47
18  27  46
18  28  45
18  29  44
18  30  43
18  31  42
18  32  41
18  33  40
18  34  39
18  35  38
18  36  37
18  73  90
18  74  89
18  75  88
18  76  87
18  77  86
18  78  85
18  79  84
18  80  83
18  81  82
19  20  52
19  21  51
19  22  50
19  23  49
19  24  48
19  25  47
19  26  46
19  27  45
19  28  44
19  29  43
19  30  42
19  31  41
19  32  40
19  33  39
19  34  38
19  35  37
19  72  90
19  73  89
19  74  88
19  75  87
19  76  86
19  77  85
19  78  84
19  79  83
19  80  82
20  21  50
20  22  49
20  23  48
20  24  47
20  25  46
20  26  45
20  27  44
20  28  43
20  29  42
20  30  41
20  31  40
20  32  39
20  33  38
20  34  37
20  35  36
20  71  90
20  72  89
20  73  88
20  74  87
20  75  86
20  76  85
20  77  84
20  78  83
20  79  82
20  80  81
21  22  48
21  23  47
21  24  46
21  25  45
21  26  44
21  27  43
21  28  42
21  29  41
21  30  40
21  31  39
21  32  38
21  33  37
21  34  36
21  70  90
21  71  89
21  72  88
21  73  87
21  74  86
21  75  85
21  76  84
21  77  83
21  78  82
21  79  81
22  23  46
22  24  45
22  25  44
22  26  43
22  27  42
22  28  41
22  29  40
22  30  39
22  31  38
22  32  37
22  33  36
22  34  35
22  69  90
22  70  89
22  71  88
22  72  87
22  73  86
22  74  85
22  75  84
22  76  83
22  77  82
22  78  81
22  79  80
23  24  44
23  25  43
23  26  42
23  27  41
23  28  40
23  29  39
23  30  38
23  31  37
23  32  36
23  33  35
23  68  90
23  69  89
23  70  88
23  71  87
23  72  86
23  73  85
23  74  84
23  75  83
23  76  82
23  77  81
23  78  80
24  25  42
24  26  41
24  27  40
24  28  39
24  29  38
24  30  37
24  31  36
24  32  35
24  33  34
24  67  90
24  68  89
24  69  88
24  70  87
24  71  86
24  72  85
24  73  84
24  74  83
24  75  82
24  76  81
24  77  80
24  78  79
25  26  40
25  27  39
25  28  38
25  29  37
25  30  36
25  31  35
25  32  34
25  66  90
25  67  89
25  68  88
25  69  87
25  70  86
25  71  85
25  72  84
25  73  83
25  74  82
25  75  81
25  76  80
25  77  79
26  27  38
26  28  37
26  29  36
26  30  35
26  31  34
26  32  33
26  65  90
26  66  89
26  67  88
26  68  87
26  69  86
26  70  85
26  71  84
26  72  83
26  73  82
26  74  81
26  75  80
26  76  79
26  77  78
27  28  36
27  29  35
27  30  34
27  31  33
27  64  90
27  65  89
27  66  88
27  67  87
27  68  86
27  69  85
27  70  84
27  71  83
27  72  82
27  73  81
27  74  80
27  75  79
27  76  78
28  29  34
28  30  33
28  31  32
28  63  90
28  64  89
28  65  88
28  66  87
28  67  86
28  68  85
28  69  84
28  70  83
28  71  82
28  72  81
28  73  80
28  74  79
28  75  78
28  76  77
29  30  32
29  62  90
29  63  89
29  64  88
29  65  87
29  66  86
29  67  85
29  68  84
29  69  83
29  70  82
29  71  81
29  72  80
29  73  79
29  74  78
29  75  77
30  61  90
30  62  89
30  63  88
30  64  87
30  65  86
30  66  85
30  67  84
30  68  83
30  69  82
30  70  81
30  71  80
30  72  79
30  73  78
30  74  77
30  75  76
31  60  90
31  61  89
31  62  88
31  63  87
31  64  86
31  65  85
31  66  84
31  67  83
31  68  82
31  69  81
31  70  80
31  71  79
31  72  78
31  73  77
31  74  76
32  59  90
32  60  89
32  61  88
32  62  87
32  63  86
32  64  85
32  65  84
32  66  83
32  67  82
32  68  81
32  69  80
32  70  79
32  71  78
32  72  77
32  73  76
32  74  75
33  58  90
33  59  89
33  60  88
33  61  87
33  62  86
33  63  85
33  64  84
33  65  83
33  66  82
33  67  81
33  68  80
33  69  79
33  70  78
33  71  77
33  72  76
33  73  75
34  57  90
34  58  89
34  59  88
34  60  87
34  61  86
34  62  85
34  63  84
34  64  83
34  65  82
34  66  81
34  67  80
34  68  79
34  69  78
34  70  77
34  71  76
34  72  75
34  73  74
35  56  90
35  57  89
35  58  88
35  59  87
35  60  86
35  61  85
35  62  84
35  63  83
35  64  82
35  65  81
35  66  80
35  67  79
35  68  78
35  69  77
35  70  76
35  71  75
35  72  74
36  55  90
36  56  89
36  57  88
36  58  87
36  59  86
36  60  85
36  61  84
36  62  83
36  63  82
36  64  81
36  65  80
36  66  79
36  67  78
36  68  77
36  69  76
36  70  75
36  71  74
36  72  73
37  54  90
37  55  89
37  56  88
37  57  87
37  58  86
37  59  85
37  60  84
37  61  83
37  62  82
37  63  81
37  64  80
37  65  79
37  66  78
37  67  77
37  68  76
37  69  75
37  70  74
37  71  73
38  53  90
38  54  89
38  55  88
38  56  87
38  57  86
38  58  85
38  59  84
38  60  83
38  61  82
38  62  81
38  63  80
38  64  79
38  65  78
38  66  77
38  67  76
38  68  75
38  69  74
38  70  73
38  71  72
39  52  90
39  53  89
39  54  88
39  55  87
39  56  86
39  57  85
39  58  84
39  59  83
39  60  82
39  61  81
39  62  80
39  63  79
39  64  78
39  65  77
39  66  76
39  67  75
39  68  74
39  69  73
39  70  72
40  51  90
40  52  89
40  53  88
40  54  87
40  55  86
40  56  85
40  57  84
40  58  83
40  59  82
40  60  81
40  61  80
40  62  79
40  63  78
40  64  77
40  65  76
40  66  75
40  67  74
40  68  73
40  69  72
40  70  71
41  50  90
41  51  89
41  52  88
41  53  87
41  54  86
41  55  85
41  56  84
41  57  83
41  58  82
41  59  81
41  60  80
41  61  79
41  62  78
41  63  77
41  64  76
41  65  75
41  66  74
41  67  73
41  68  72
41  69  71
42  49  90
42  50  89
42  51  88
42  52  87
42  53  86
42  54  85
42  55  84
42  56  83
42  57  82
42  58  81
42  59  80
42  60  79
42  61  78
42  62  77
42  63  76
42  64  75
42  65  74
42  66  73
42  67  72
42  68  71
42  69  70
43  48  90
43  49  89
43  50  88
43  51  87
43  52  86
43  53  85
43  54  84
43  55  83
43  56  82
43  57  81
43  58  80
43  59  79
43  60  78
43  61  77
43  62  76
43  63  75
43  64  74
43  65  73
43  66  72
43  67  71
43  68  70
44  47  90
44  48  89
44  49  88
44  50  87
44  51  86
44  52  85
44  53  84
44  54  83
44  55  82
44  56  81
44  57  80
44  58  79
44  59  78
44  60  77
44  61  76
44  62  75
44  63  74
44  64  73
44  65  72
44  66  71
44  67  70
44  68  69
45  46  90
45  47  89
45  48  88
45  49  87
45  50  86
45  51  85
45  52  84
45  53  83
45  54  82
45  55  81
45  56  80
45  57  79
45  58  78
45  59  77
45  60  76
45  61  75
45  62  74
45  63  73
45  64  72
45  65  71
45  66  70
45  67  69
46  47  88
46  48  87
46  49  86
46  50  85
46  51  84
46  52  83
46  53  82
46  54  81
46  55  80
46  56  79
46  57  78
46  58  77
46  59  76
46  60  75
46  61  74
46  62  73
46  63  72
46  64  71
46  65  70
46  66  69
46  67  68
47  48  86
47  49  85
47  50  84
47  51  83
47  52  82
47  53  81
47  54  80
47  55  79
47  56  78
47  57  77
47  58  76
47  59  75
47  60  74
47  61  73
47  62  72
47  63  71
47  64  70
47  65  69
47  66  68
48  49  84
48  50  83
48  51  82
48  52  81
48  53  80
48  54  79
48  55  78
48  56  77
48  57  76
48  58  75
48  59  74
48  60  73
48  61  72
48  62  71
48  63  70
48  64  69
48  65  68
48  66  67
49  50  82
49  51  81
49  52  80
49  53  79
49  54  78
49  55  77
49  56  76
49  57  75
49  58  74
49  59  73
49  60  72
49  61  71
49  62  70
49  63  69
49  64  68
49  65  67
50  51  80
50  52  79
50  53  78
50  54  77
50  55  76
50  56  75
50  57  74
50  58  73
50  59  72
50  60  71
50  61  70
50  62  69
50  63  68
50  64  67
50  65  66
51  52  78
51  53  77
51  54  76
51  55  75
51  56  74
51  57  73
51  58  72
51  59  71
51  60  70
51  61  69
51  62  68
51  63  67
51  64  66
52  53  76
52  54  75
52  55  74
52  56  73
52  57  72
52  58  71
52  59  70
52  60  69
52  61  68
52  62  67
52  63  66
52  64  65
53  54  74
53  55  73
53  56  72
53  57  71
53  58  70
53  59  69
53  60  68
53  61  67
53  62  66
53  63  65
54  55  72
54  56  71
54  57  70
54  58  69
54  59  68
54  60  67
54  61  66
54  62  65
54  63  64
55  56  70
55  57  69
55  58  68
55  59  67
55  60  66
55  61  65
55  62  64
56  57  68
56  58  67
56  59  66
56  60  65
56  61  64
56  62  63
57  58  66
57  59  65
57  60  64
57  61  63
58  59  64
58  60  63
58  61  62
59  60  62

 

88 lines ( 3 cols) with   local nValore:= 1     local nTipo := 2

this :

Code: Select all  Expand view

1   2   3
2   3   4
3   4   5
4   5   6
5   6   7
6   7   8
7   8   9
8   9   10
9   10  11
10  11  12
11  12  13
12  13  14
13  14  15
14  15  16
15  16  17
16  17  18
17  18  19
18  19  20
19  20  21
20  21  22
21  22  23
22  23  24
23  24  25
24  25  26
25  26  27
26  27  28
27  28  29
28  29  30
29  30  31
30  31  32
31  32  33
32  33  34
33  34  35
34  35  36
35  36  37
36  37  38
37  38  39
38  39  40
39  40  41
40  41  42
41  42  43
42  43  44
43  44  45
44  45  46
45  46  47
46  47  48
47  48  49
48  49  50
49  50  51
50  51  52
51  52  53
52  53  54
53  54  55
54  55  56
55  56  57
56  57  58
57  58  59
58  59  60
59  60  61
60  61  62
61  62  63
62  63  64
63  64  65
64  65  66
65  66  67
66  67  68
67  68  69
68  69  70
69  70  71
70  71  72
71  72  73
72  73  74
73  74  75
74  75  76
75  76  77
76  77  78
77  78  79
78  79  80
79  80  81
80  81  82
81  82  83
82  83  84
83  84  85
84  85  86
85  86  87
86  87  88
87  88  89
88  89  90


one line
with   local nValore:= 3
    local nTipo := 3

Code: Select all  Expand view
1   2   3


88 lines
with   local nValore:= 2
    local nTipo := 4


Code: Select all  Expand view
1   2   3
2   3   4
3   4   5
4   5   6
5   6   7
6   7   8
7   8   9
8   9   10
9   10  11
10  11  12
11  12  13
12  13  14
13  14  15
14  15  16
15  16  17
16  17  18
17  18  19
18  19  20
19  20  21
20  21  22
21  22  23
22  23  24
23  24  25
24  25  26
25  26  27
26  27  28
27  28  29
28  29  30
29  30  31
30  31  32
31  32  33
32  33  34
33  34  35
34  35  36
35  36  37
36  37  38
37  38  39
38  39  40
39  40  41
40  41  42
41  42  43
42  43  44
43  44  45
44  45  46
45  46  47
46  47  48
47  48  49
48  49  50
49  50  51
50  51  52
51  52  53
52  53  54
53  54  55
54  55  56
55  56  57
56  57  58
57  58  59
58  59  60
59  60  61
60  61  62
61  62  63
62  63  64
63  64  65
64  65  66
65  66  67
66  67  68
67  68  69
68  69  70
69  70  71
70  71  72
71  72  73
72  73  74
73  74  75
74  75  76
75  76  77
76  77  78
77  78  79
78  79  80
79  80  81
80  81  82
81  82  83
82  83  84
83  84  85
84  85  86
85  86  87
86  87  88
87  88  89
88  89  90





I tried with your test and there is an error I explain you
I tested with
local nValore:= 6
local nTipo := 3

at the end I have this

Image

as you can see this is wrong because

line 2 is same of line 4
then line 3 there are 3 same numbers

it must be as
Image
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: 6849
Joined: Thu Oct 18, 2012 7:17 pm

Re: delete identical records

Postby Silvio.Falconi » Wed Nov 02, 2022 10:05 am

change into

For n= 1 to 90
For k= 1 to 90
For j= 1 to 90
nTotale := Calcolo_3_numeri(n,k,j,ntipo)
If nTotale=nvalore
nAt := AScan( aTmp, { |a| a[1] = j .and. a[2] = k .or. a[3] = n} )
If nAt == 0
aadd(aTmp,{n,k,j})
Endif
Endif

next
next
next

the calc is fast but is also bad because there are also duples

sample :

Image
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: 6849
Joined: Thu Oct 18, 2012 7:17 pm

Re: delete identical records

Postby Silvio.Falconi » Wed Nov 02, 2022 10:55 am

sorry my error

Now only with local nValore:= 6
local nTipo := 3


run ok

For n= 1 to 90
For k= 1 to 90
For j= 1 to 90
nTotale := Calcolo_3_numeri(n,k,j,ntipo)
If nTotale=nvalore
nAt := AScan( aTmp, { |a| a[1] = k .and. a[2] = n .or. a[3] = j } )
If nAt == 0
aadd(aTmp,{n,k,j})
Endif
Endif
next
next
next

I understood the error is here
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: 6849
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 40 guests