본문 바로가기
CodeSignal/Arcade

CodeSignal [60/60] sudoku

by 벤진[Benzene] 2020. 5. 28.

Problem:

Sudoku is a number-placement puzzle. The objective is to fill a 9 × 9 grid with digits so that each column, each row, and each of the nine 3 × 3 sub-grids that compose the grid contains all of the digits from 1 to 9.

This algorithm should check if the given grid of numbers represents a correct solution to Sudoku.

 

Example

  • For

the output should be
sudoku(grid) = true;

  • For

the output should be
sudoku(grid) = false.

The output should be false: each of the nine 3 × 3 sub-grids should contain all of the digits from 1 to 9.
These examples are represented on the image below.

 

 

-Summary-

1. Create a 3 different function to check if it is valid sudoku (row/col/3x3 box).

2. Loop through each function and check if it is valid.

3. Return true if all function pass.

 

모든 문제에 대한 저작권은 CodeSignal 회사에 있습니다. [Copyright © 2020 BrainFights Inc. All rights reserved]

https://codesignal.com/

'CodeSignal > Arcade' 카테고리의 다른 글

CodeSignal [59/60] spiralNumbers  (0) 2020.05.28
CodeSignal [58/60] messageFromBinaryCode  (0) 2020.05.28
CodeSignal [57/60] fileNaming  (0) 2020.05.28
CodeSignal [56/60] digitsProduct  (0) 2020.05.28
CodeSignal [55/60] differentSquares  (0) 2020.05.28

댓글