Du kombinierst einfach Ollis genialen Einfall und meinen Schwachsinn und dann erhältst du sowas:
Delphi-Quellcode:
function BigToSmall(
iBigCol, iBigRow: Integer;
var iBlockCol, iBlockRow, iSmallCol, iSmallRow: Integer
): Boolean;
begin
Result := (iBigCol in [0..8]) and (iBigRow in [0..8]);
if Result then
begin
iBlockCol := iBigCol div 3;
iBlockRow := iBigRow div 3;
iSmallCol := iBigCol mod 3;
iSmallRow := iBigRow mod 3;
end;
end;
function SmallToBig(
iBlockCol, iBlockRow, iSmallCol, iSmallRow: Integer;
var iBigCol, iBigRow: Integer
): Boolean;
begin
Result := (iBlockCol in [0..2]) and (iBlockRow in [0..2])
and (iSmallCol in [0..2]) and (iSmallRow in [0..2]);
if Result then
begin
iBigCol := 3 * iBlockCol + iSmallCol;
iBigRow := 3 * iBlockRow + iSmallRow;
end;
end;
Freundliche Grüße vom marabu