From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.107.18.161 with SMTP id 33mr27068275ios.8.1514595108338; Fri, 29 Dec 2017 16:51:48 -0800 (PST) X-Received: by 10.157.39.12 with SMTP id r12mr1339958ota.4.1514595108214; Fri, 29 Dec 2017 16:51:48 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.am4!peer.am4.highwinds-media.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!g80no3868039itg.0!news-out.google.com!b73ni14750ita.0!nntp.google.com!i6no3874874itb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 29 Dec 2017 16:51:48 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2601:645:c001:2a91:c4bf:3cd5:b3e0:216a; posting-account=fxr6CwoAAABjARAbZ01okNaxDpxQT8RH NNTP-Posting-Host: 2601:645:c001:2a91:c4bf:3cd5:b3e0:216a User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <1c10eec9-040c-4d50-a557-11325883529a@googlegroups.com> Subject: =?UTF-8?B?QXJyYXlzLCBzbGljZXMsIGNhc2UsIGFuZCDigJhpbuKAmSBzdHJhdGVnaWVz?= From: Mace Ayres Injection-Date: Sat, 30 Dec 2017 00:51:48 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Received-Body-CRC: 1693376625 X-Received-Bytes: 4155 Xref: reader02.eternal-september.org comp.lang.ada:49691 Date: 2017-12-29T16:51:48-08:00 List-Id: I have a two dimensional array, gird, 1..9, 1..9 index of integer and array= of a record type named cell and array is named grid. So, a grid is a 9x9 = array of record type =E2=80=98cell, Cell has some properties, and functions= in the containing package to enter, change, values in a field called =E2= =80=98value. So I can traverse the array named grid with for row in 1..9 loop for column 1..9 loop grid(row,column).x :=3D y; =E2=80=94 x is some attribute of the c= ell/record/object that the array is type of end loop; =E2=80=94 column loop. =E2=80=94 and y is some value I ass= ign to the x field, of the object cell in the array location (row, column) end loop; =E2=80=94 row loop When attempting to assign a y value to the cell=E2=80=99s x field, I want t= o to check that the y that is to be assigned to the cell=E2=80=99s x field = does not adready exist anywhere adready in all the columns of the row, or a= ll the rows of the target column. Easy enough with function:=20 Check_row.(r,c, numb: Integer ... boolean .. begin for c in 1..9 loop. =E2=80=94 traverse the row in grid tha= t is passed in with parm r if grid(r).value =3D numb =E2=80=94 if if grid(r,c).value =3D numb.= =E2=80=94 numb is passed in also a parm then bad. =E2=80=94 proposed value numb already= exists in proposed row to put it in return false =E2=80=94 not ok ..... function check_column uses some logic. Both work and are fast enough on my = 64bit Mac OS x. Now, challenge is: besides checking to see if a proposed value (integer 1..= 0) already exists in the proposed row and column to put it in, I also have an abstraction of triads superimposed (mentally) on the grid, g= iving 9 triads layer on top of the 9x9 array called =E2=80=98grid.=E2=80=99= The 9x9 grid nicely holds 9 of these imaginary triads,, ie, first 3 rows and first 3 columns ar= e in triad 1 and first 3 rows and columns 4 to 6 are conceived as triad 2, I need to check, in addition to whether the proposed ingteger value is alre= ady in any cells in that row, or column, whether the proposed value alread= y exists in any cell.value field for any cell in triad. The in parameters of = r,c can reveal what triad is in question, but it looks like some fat code t= o to traverse the abstract 3x3 triads. I know I could create some triad types of arrays, but I am wondering if I c= an slice the array grid into 9 collections and then check loop.. if numb (proposed number) already exists in the triad [this would be= determined by row, column in parameters) OR also, the cell/record has a fi= eld with its triad, a constant property. If this is too convoluted and or not clear, I can just delete the question,= but if it=E2=80=99s understandable, best approach recommended appreciated. =20