Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please code this on matlab! makeSudoko.m Sudoko.m function grid = makeSudoku(seed,n_empty) % Generates a Sudoku puzzle % seed - random generation seed % n_remove -

please code this on matlab!

makeSudoko.m

Sudoko.m

function grid = makeSudoku(seed,n_empty)

% Generates a Sudoku puzzle

% seed - random generation seed

% n_remove - number of empty spots in the puzzle

% Note: Puzzles become increasingly difficult as n_empty is increased

% Also, puzzle made eventually reach a point where multiple solutions

% exist if n_remove is pushed to very high values.

% Seed the random number generator with our seed input,

% then generate a base sequence for making the grid

rng(seed);

base = randperm(9);

% Fill out the grid based on base sequence

for i = 1:9

k = [1 4 7 2 5 8 3 6 9];

grid(i,:) = [base(k(i):9) base(1:k(i)-1)];

end

% Remove values from the grid to make empty spots

grid(randperm(81,n_empty)) = 0;

end

solve sudoko puzzle

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro Android Graphics

Authors: Wallace Jackson

1st Edition

1430257857, 978-1430257851

More Books

Students also viewed these Programming questions

Question

=+What can you conclude?

Answered: 1 week ago