I think I have the functions down, but I don't know how to link them. Should I put the sudoku functions in main?

The instructions are as follows:

"At the moment, the cursor is "stuck" in the board’s center. Enable users to move that cursor up, down, left, and right by way of their keyboard’s arrow keys. You’re welcome to support other keys for movement as well, but you must support KEY_UP, KEY_DOWN, KEY_LEFT, and KEY_RIGHT, constants that represent the characters fed to ncurses' getch function when arrow keys are pressed. (See the man page for getch for even more constants.) You should only allow the user to move his or her cursor to coordinates where there are actual numbers or blanks (i.e., the cursor should "hop over" one-character lateral gaps between cells as well as the innermost crossbars that make up the grid’s lines), but you should find that the arithmetic already implemented in show_cursor helps with that! Even though you might be tempted to make the cursor hop over numbers that came with the board, resist the temptation; allow the cursor to be in any one of those 81 cells.

Enable the cursor to also "wrap around" from the top row to the bottom, bottom to top, left to right, or right to left if the user presses KEY_UP, KEY_DOWN, KEY_LEFT, or KEY_RIGHT, respectively, too many times.

Enable the user to replace any blank with a number by moving his or her cursor over that blank and then hitting a number from 1 to 9.

Enable the user to change a number that they already inputted back to a blank by hitting any of 0, a period, KEY_BACKSPACE, or KEY_DC or to some other number from 1 to 9 by hitting that number.[8] You needn’t (yet) prevent the user from altering numbers that "came with" the board.

Just implementing these two features (movements and number entry) will allow users to play (and win!) the game of Sudoku…​ but even if they fill in all the numbers correctly, they won’t know it quite yet! We’ll complete the implementation of Sudoku in the next portion of this problem."

It doesn't say anything about checking for winning or anything.

What prototypes am I supposed to implement?

1 Answer 1


Full disclosure: I am a CS50 edX student. There is not a sudoku problem set in the 2015/16 versions of the course.

From reading the instructions, it sounds like you need to implement (at least) 2 functions - "movements" and "number entry". Since the names are not prescribed, it sounds like you can name them anything you wish. The only way these functions can be used by the sudoku program is if they are incorporated in main, similar to the way the supplied prototype/functions are. (Technically they could be implemented in an other file and called by main with a #include and Makefile changes.) You will find the requirements for the rest of "the implementation of Sudoku [eg winning] in the next portion of this problem".

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .