comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Arrays, slices, case, and ‘in’ strategies
Date: Sat, 30 Dec 2017 17:41:53 +0000
Date: 2017-12-30T17:41:53+00:00	[thread overview]
Message-ID: <lyy3lkcdum.fsf@pushface.org> (raw)
In-Reply-To: ly373seb7x.fsf@pushface.org

Simon Wright <simon@pushface.org> writes:

> Mace Ayres <mace.ayres@gmail.com> 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;

  parent reply	other threads:[~2017-12-30 17:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-30  0:51 Arrays, slices, case, and ‘in’ strategies Mace Ayres
2017-12-30  8:34 ` Jacob Sparre Andersen
2017-12-30 17:20   ` Mace Ayres
2017-12-30 17:30   ` Mace Ayres
2017-12-30  9:58 ` Jeffrey R. Carter
2017-12-30 17:32   ` Mace Ayres
2017-12-30 10:55 ` Simon Wright
2017-12-30 17:12   ` Mace Ayres
2017-12-30 17:41   ` Simon Wright [this message]
2017-12-30 23:52     ` Mace Ayres
2017-12-31  9:09       ` Simon Wright
2017-12-31 20:14 ` Robert Eachus
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox