The Student Room Group

C++ sudoku coursework please help!!

Hey!

So we've started learning c++ only recently so Im still bit new to the syntax and they've given a coursework about making a sudoku game which I'm finding incredibly hard to get my head around it.

Anyone a bit of a wise owl in the subject ? Then I can go into the deets!
Thanks! :smile:
Sure why not. I'm good at C++. What are you struggling with?
Reply 2
Original post by BobBobson
Sure why not. I'm good at C++. What are you struggling with?


So, I'm using a 3D vector to make the puzzle. But I'm struggling with the algorithm for setting the value inside square in the board and removing all the other same values from the other boxes.

So I'm making a vector1<vector2<vector3<int> > > as the board.
Vector 3 is the values till 9 and then Im trying to remove all the other possibilities when 1 no. is selected.
Original post by a9493r
So, I'm using a 3D vector to make the puzzle. But I'm struggling with the algorithm for setting the value inside square in the board and removing all the other same values from the other boxes.

So I'm making a vector1 as the board.
Vector 3 is the values till 9 and then Im trying to remove all the other possibilities when 1 no. is selected.


So say your 3d vector is called vec.
And then the user picks x on the square with coordinates a and b. You want that squares respective vector to only contain the digit 1.
So you say:

vec[a] = {x};

And obviously it doesn't have to be 1, it could be any integer variable.

Then you loop through the whole row.
[code]
for (int i = 0; i
Reply 4
[QUOTE="BobBobson;68463640"]So say your 3d vector is called vec.
And then the user picks x on the square with coordinates a and b. You want that squares respective vector to only contain the digit 1.
So you say:


vec[a] = {x};


And obviously it doesn't have to be 1, it could be any integer variable.

Then you loop through the whole row.

for (int i = 0; i


Thanks! I was working on a similar logic...had got a Segmentation error that took agess to fix but worked! Thanks :smile:

Quick Reply

Latest

Trending

Trending