Sudoku Programmers Forum Index

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log inLog in          Games  Calendar

Log in to check your private messagesLog in to check your private messages   

row R and column C numbers

 
Post new topic   Reply to topic    Sudoku Programmers Forum Index -> Programming sudoku
View previous topic :: View next topic  
Author Message
ChPicard

Joined: 12 Mar 2008
Posts: 82
:
Location: Montreal, Canada

Items
PostPosted: Wed Aug 12, 2009 8:31 pm    Post subject: row R and column C numbers Reply with quote

Hi

How to calculate the row R and column C numbers knowing the position X of the givens (X>=0 and X<81) ?

Thank you
Back to top
View user's profile Send private message
Pete

Joined: 09 Jun 2008
Posts: 18
:
Location: Somerset, NJ

Items
PostPosted: Wed Aug 12, 2009 8:47 pm    Post subject: Reply with quote

Assuming a 9x9 grid, I would think that

* R would be X / 9

* C would be X % 9

where % is the modulo operator.

That would give a number from 0 to 8 for each. Of course, you could add 1 to each if you want the range to be 1 to 9.

Is that what you're looking for?
Back to top
View user's profile Send private message AIM Address
leeo

Joined: 24 Jun 2009
Posts: 6
:
Location: USA NW

Items
PostPosted: Tue Aug 25, 2009 12:46 pm    Post subject: Reply with quote

Sudoku grids are small enough that defining arrays may be faster than working with calculating the position. One array I have lists each of the 20 cells touching each of the 81 cells in the grid. This array has 1620 elements, but the calculation need only be done once, on building the array. Further, an inefficient "brute force" search can be employed to build the arrays, and the employment of the array will still be efficient.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Sudoku Programmers Forum Index -> Programming sudoku All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Sudoku Programmers topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group

Igloo Theme Version 1.0 :: Created By: Andrew Charron