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 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Arrays, slices, case, and =?utf-8?B?4oCYaW7igJk=?= strategies Date: Sat, 30 Dec 2017 17:41:53 +0000 Organization: A noiseless patient Spider Message-ID: References: <1c10eec9-040c-4d50-a557-11325883529a@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="bf670cb6d648c9f947e8167df8ed1562"; logging-data="4461"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19iVVfDbQ/Lzjh/XFyj3JjGIDqXlWdkRHc=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (darwin) Cancel-Lock: sha1:H54waIhhbf99NVngeVPvJtRUpTQ= sha1:+/EHXv5wxVTWjKMBXBkC3lvxWBY= Xref: reader02.eternal-september.org comp.lang.ada:49702 Date: 2017-12-30T17:41:53+00:00 List-Id: 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: 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;