Jump to content


Programming Challenge: Sudoku Grid


1 reply to this topic

#1 raydricspellthorn

    New Member

  • Members
  • Pip
  • 1 posts

Posted 05 December 2007 - 02:01 PM

I have one challenge, that i could not solve :lol:

I have those grids:

http://img62.imagesh...okubg4x4jx9.png

http://img218.images...okubg6x6ib7.jpg

http://img80.imagesh...okubg9x9zm6.jpg

And i want to make a loop that read the number from the grid[x][y] and put it in the correct position (centralized) in the grid square...

Naturally we could make this: theX * cellSize... but we have the thin lines and the big lines, that influences the position...

The position has to be: sudokuBoardX + (gridX * cellSize) + bigLinesOffset + thinLinesOffset; so it will be exactly in the square position, thats what i want =)

So my problem is: how to calculate the lines offset so i can draw the numbers in the correct position in the grid?

I have been talking to many programmer friends as i could, but i did not understand how to solve it (its my third day trying =/ )...

I need a solution to use on images, not to draw the lines or stuff like that


The grid have some variables: cellSize, lineInterval (number of blocks in each division, in the case of the 9 x 9 grid, the interval is 3, because it is divided in a series of 3 x 3 blocks), the big line width and the thin line width, and i have all of these in my SudokuGrid class. I just need some clues about how to calculate the line offset so i can draw the number perfectly (depending on the position in the grid).

I am using C++

Thanks a lot!

#2 LmT

    New Member

  • Members
  • PipPip
  • 15 posts

Posted 06 December 2007 - 06:53 AM

You could create a grid object and a cell object and position the cells correctly. Then all you would have to do is display the image in the center of a cell--you don't have to worry about the width of the lines.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users