softnshare / kata

Code Kata 這個概念是由 The Pragmatic Programmer 的作者之一Dave Thomas提出的, 想要提升自己的coding skill嗎? 歡迎加入這個slack channel, 加入請參考右邊網頁說明
https://softnshare.wordpress.com/slack/kata/
38 stars 4 forks source link

Did I Finish my Sudoku? #9

Open jawayang opened 8 years ago

jawayang commented 8 years ago

題目:http://www.codewars.com/kata/did-i-finish-my-sudoku/ 敘述: Write a function done_or_not passing a board (list[list_lines]) as parameter. If the board is valid return 'Finished!', otherwise return 'Try again!'

Sudoku rules:

Complete the Sudoku puzzle so that each and every row, column, and region contains the numbers one through nine only once.

Rows:

There are 9 rows in a traditional Sudoku puzzle. Every row must contain the numbers 1, 2, 3, 4, 5, 6, 7, 8, and 9. There may not be any duplicate numbers in any row. In other words, there can not be any rows that are identical.

In the illustration the numbers 5, 3, 1, and 2 are the "givens". They can not be changed. The remaining numbers in black are the numbers that you fill in to complete the row.

Columns:

There are 9 columns in a traditional Sudoku puzzle. Like the Sudoku rule for rows, every column must also contain the numbers 1, 2, 3, 4, 5, 6, 7, 8, and 9. Again, there may not be any duplicate numbers in any column. Each column will be unique as a result.

In the illustration the numbers 7, 2, and 6 are the "givens". They can not be changed. You fill in the remaining numbers as shown in black to complete the column.

Regions

A region is a 3x3 box like the one shown to the left. There are 9 regions in a traditional Sudoku puzzle.

Like the Sudoku requirements for rows and columns, every region must also contain the numbers 1, 2, 3, 4, 5, 6, 7, 8, and 9. Duplicate numbers are not permitted in any region. Each region will differ from the other regions.

In the illustration the numbers 1, 2, and 8 are the "givens". They can not be changed. Fill in the remaining numbers as shown in black to complete the region.

For those who don't know the game, here are some information about rules and how to play Sudoku: http://en.wikipedia.org/wiki/Sudoku and http://www.sudokuessentials.com/

翻譯: 寫一個函式,去確認完成的數獨是否正確,其中會需要去確認每一列、每一行、每一個區域(3*3block)都包含1~9的數字。

@vicky-sunshine

d2207197 commented 8 years ago

Pass

bucker commented 8 years ago

Pass