| evert
| Joined: 30 Aug 2005 | Posts: 68 | : | Location: Amsterdam | Items |
|
Posted: Mon Nov 28, 2005 10:57 pm Post subject: Translating rownr/colnr to boxnr/cellnr within box |
|
|
I just found out that the function that translates rownrs/colnrs into
boxnrs/cellnrs inverts itself:
Code: |
function Trfi(i, j : integer) : integer;
begin
result := (((i - 1) div 3) * 3) + ((j - 1) div 3) + 1;
end;
function Trfj(i, j : integer) : integer;
begin
result := (((i - 1) mod 3) * 3) + ((j - 1) mod 3) + 1;
end;
// boxnr := Trfi(rownr,colnr);
// bcellnr := Trfj(rownr,colnr);
// rownr := Trfi(boxnr,bcellnr);
// colnr := Trfj(boxnr,bcellnr);
|
|
|