AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Sudoku Array of Array vergleichen

Ein Thema von Marcel2906 · begonnen am 4. Nov 2011 · letzter Beitrag vom 3. Dez 2012
 
Bjoerk

Registriert seit: 28. Feb 2011
Ort: Mannheim
1.384 Beiträge
 
Delphi 10.4 Sydney
 
#21

AW: Sudoku Array of Array vergleichen

  Alt 20. Nov 2011, 16:43
Für die Sudoku Fans:

Delphi-Quellcode:
function BlockToRowCol(Block, Index: integer): TPoint;
begin
  // Block 0..8, Index 0..8
  // Result.X = Row 0..8, Result.Y = Col 0..8
  Result.X:= (Block div 3) * 3 + Index div 3;
  Result.Y:= (Block mod 3) * 3 + (Index + 3) mod 3;
end;

function RowColToBlock(Row, Col: integer): TPoint;
begin
  // Row 0..8, Col 0..8
  // Result.X = Block 0..8, Result.Y = Index 0..8
  Result.X:= Row div 3 mod 3 * 3 + Col div 3 mod 3;
  Result.Y:= Row mod 3 * 3 + Col mod 3;
end;

function IndexToRowCol(K: integer): TPoint;
begin
  // K 0..80
  // Result.X = Row 0..8, Result.Y = Col 0..8
  Result.X:= K div 9;
  Result.Y:= K - Result.X * 9;
end;

function RowColToIndex(Row, Col: integer): integer;
begin
  // Row 0..8, Col 0..8
  // Result = K 0..80
  Result:= Row * 9 + Col;
end;

Geändert von Bjoerk (20. Nov 2011 um 16:58 Uhr) Grund: TPoint
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 00:16 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz