Wednesday, October 29, 2014

一道面试题: next sudoku

发信人: DAOLAIAMENG (熊熊), 信区: JobHunting
标  题: 一道面试题: next sudoku
关键字: 面试题
发信站: BBS 未名空间站 (Tue Oct 28 11:16:31 2014, 美东)

很早以前面过的一道题,Sudoku Solver的变种
设计一个function,每call一次,return一个next sudoku result.(next是按照数字大
小的顺序)
这种题,会同时考察 coding+design(如何设计API)

例如
sudoku puzzle starts with the below board
{1, 2, 3, 4, 5, 6, 7, 8, 9,
4, 5, 6, 7, 8, 9, 1, 2, 3,
7, 8, 9, 1, 2, 3, 4, 5, 6,
2, 1, 4, 3, 6, 5, 8, 9, 7,
3, 6, 5, 8, 9, 7, 2, 1, 4,
8, 9, 7, 2, 1, 4, 3, 6, 5,
5, 3, 1, 6, 4, 2, 9, 7, 8,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0};
The #1 solution is:
{1, 2, 3, 4, 5, 6, 7, 8, 9,
4, 5, 6, 7, 8, 9, 1, 2, 3,
7, 8, 9, 1, 2, 3, 4, 5, 6,
2, 1, 4, 3, 6, 5, 8, 9, 7,
3, 6, 5, 8, 9, 7, 2, 1, 4,
8, 9, 7, 2, 1, 4, 3, 6, 5,
5, 3, 1, 6, 4, 2, 9, 7, 8,
6, 4, 2, 9, 7, 8, 5, 3, 1,
9, 7, 8, 5, 3, 1, 6, 4, 2}
The #2 solution is:
{1, 2, 3, 4, 5, 6, 7, 8, 9,
4, 5, 6, 7, 8, 9, 1, 2, 3,
7, 8, 9, 1, 2, 3, 4, 5, 6,
2, 1, 4, 3, 6, 5, 8, 9, 7,
3, 6, 5, 8, 9, 7, 2, 1, 4,
8, 9, 7, 2, 1, 4, 3, 6, 5,
5, 3, 1, 6, 4, 2, 9, 7, 8,
6, 4, 8, 9, 7, 1, 5, 3, 2,
9, 7, 2, 5, 3, 8, 6, 4, 1}
and so on...
--
※ 来源:·WWW 未名空间站 网址:mitbbs.com 移动:在应用商店搜索未名空间·[FROM: 76.]

http://www.mitbbs.com/article_t/JobHunting/32815401.html

No comments:

Post a Comment