ナンバープレィス・数独について
「数独」・ナンバープレイスをテーマにしてプログラムで遊ぶ












  1. 水平方向のチェックを行う。
    集合配列の初期値は
    すべて配置可能なので
    [ 1,2,3,4,5,6,7,8,9]
    ということになる。


    実際に置かれている数値を集合配列より減算すると
    水平方向の減算のみだと図のように
    [ 2,4,5,7,8] になる。











  2. コード
    {***************************************************
    **  水平方向 チェック
    **        []空集合は False で返す。
    **
    ****************************************************}
    function TForm1.horizon_Check(lct : TPoint):boolean;
    var
      i,x,y : integer;
    begin
      x := lct.X;
      y := lct.Y;
      result := True;
      for i := low(KnAry[x]) to high(KnAry[x]) do
        if i = y then
          continue
        else
          if DArray[x][y] in KnAry[x][i] then
            begin
              KnAry[x][i] := KnAry[x][i] - [DArray[x][y]];
              //[] 空集合
              if KnAry[x][i] = [] then
                begin
                  memo1.Lines.Add('horizon 空 False');
                  result := False;
                  exit;
                end
             end;
    end;
    
    
    
    
    
    
    引数 lct は実際に数値が入っている
    マス目の座標
    
    
    
    
     集合配列の水平方向
    
    
    
     マス目の数値が集合要素に含まれていたら
    
     集合要素からマス目の数値を減算する。
    
     結果 [ ] 空集合になったら
     中止。
      矛盾あり