We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. All Contests
  2. ProjectEuler+
  3. Project Euler #96: Su Doku

Project Euler #96: Su Doku

Problem
Submissions
Leaderboard
Discussions

This problem is a programming version of Problem 96 from projecteuler.net

Su Doku (Japanese meaning number place) is the name given to a popular puzzle concept. Its origin is unclear, but credit must be attributed to Leonhard Euler who invented a similar, and much more difficult, puzzle idea called Latin Squares. The objective of Su Doku puzzles, however, is to replace the blanks (or zeros) in a 9 by 9 grid in such that each row, column, and 3 by 3 box contains each of the digits 1 to 9. Below is an example of a typical starting puzzle grid and its solution grid.

A well constructed Su Doku puzzle has a unique solution and can be solved by logic, although it may be necessary to employ "guess and test" methods in order to eliminate options (there is much contested opinion over this). The complexity of the search determines the difficulty of the puzzle; the example above is considered easy because it can be solved by straight forward direct deduction.

You are given a number of Su Doku. All of them could be solved without guessing and even backtracking. Surely, you may write every solution that passes tests and fits into contraints.

Input Format

9 lines each containg 9 characters '0'-'9'. '0' means that the place is empty otherwise the place contains corresponding digit.

Output Format

Output the result in the same format as input with no zeroes left.

Sample Input

123456780
456780123
780123456
234567801
567801234
801234567
345678012
678012345
012345678

Sample Output

123456789
456789123
789123456
234567891
567891234
891234567
345678912
678912345
912345678

Explanation

We can see that 9 is the only digit yet to be placed. All other digits are already on their places.

Author

shashank21j

Difficulty

Hard

Max Score

100

Submitted By

2176

Need Help?


View discussions
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy