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.146.4 with SMTP id u4mr28622851iod.101.1514677954689; Sat, 30 Dec 2017 15:52:34 -0800 (PST) X-Received: by 10.157.82.148 with SMTP id f20mr1783426oth.2.1514677954531; Sat, 30 Dec 2017 15:52:34 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.unit0.net!peer03.am4!peer.am4.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!i6no4233339itb.0!news-out.google.com!b73ni16164ita.0!nntp.google.com!i6no4233338itb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 30 Dec 2017 15:52:34 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2601:645:c001:2a91:8a9:1d58:3491:d17; posting-account=fxr6CwoAAABjARAbZ01okNaxDpxQT8RH NNTP-Posting-Host: 2601:645:c001:2a91:8a9:1d58:3491:d17 References: <1c10eec9-040c-4d50-a557-11325883529a@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <3a9443fe-9540-4124-8fac-16f7ef96c810@googlegroups.com> Subject: =?UTF-8?B?UmU6IEFycmF5cywgc2xpY2VzLCBjYXNlLCBhbmQg4oCYaW7igJkgc3RyYXRlZ2llcw==?= From: Mace Ayres Injection-Date: Sat, 30 Dec 2017 23:52:34 +0000 Content-Type: text/plain; charset="UTF-8" X-Received-Bytes: 2734 X-Received-Body-CRC: 2878419818 Xref: reader02.eternal-september.org comp.lang.ada:49707 Date: 2017-12-30T15:52:34-08:00 List-Id: On Saturday, December 30, 2017 at 9:41:56 AM UTC-8, Simon Wright wrote: > Simon Wright writes: > > > Mace Ayres writes: > > > >> if ... OR also, the cell/record has a field with its triad, a constant > >> property. > > > > Don't understand this. > > Oh, I see, it's Sudoku, and those are the given cells. > > Anyway, this looks simple enough for checking whether the value is > already in the block: ============= Thanks Simon. This is exactly what I needed. My thoughts were moving toward the rythm of threes and increments in start and length of each block, but it would have taken me a while toga to the parenthesized leitmotif you capture. Excellent! Are you a professional Ada programmer? ===================== > > function Check_Block (For_Value : Integer; > At_Row : Grid_Coordinate; > At_Column : Grid_Coordinate; > In_Grid : Grid) return Boolean > is > Row_First : constant Grid_Coordinate := ((At_Row - 1) / 3) * 3 + 1; > Col_First : constant Grid_Coordinate := ((At_Column - 1) / 3) * 3 + 1; > begin > for Row in Row_First .. Row_First + 2 loop > for Col in Col_First .. Col_First + 2 loop > if In_Grid (Row, Col).X = For_Value then > return False; > end if; > end loop; > end loop; > return True; > end Check_Block;