xuebaunion@vip.163.com

3551 Trousdale Rkwy, University Park, Los Angeles, CA

留学生论文指导和课程辅导

无忧GPA：https://www.essaygpa.com

工作时间：全年无休-早上8点到凌晨3点

扫码添加客服微信

扫描添加客服微信

java代写-COMP 250

时间：2021-04-25

Final Project

COMP 250 Winter 2021

posted: Friday, Apr. 16, 2021

due: Friday, Apr. 30, 2021 at 23:59

General Instructions

• Submission instructions

– Please note that the submission deadline for the final project is very strict. No sub-

missions will be accepted after the deadline.

– As always you can submit your code multiple times but only the latest submission will

be kept. We encourage you to submit a first version a few days before the deadline

(computer crashes do happen and codePost may be overloaded during rush hours).

– This is the file you should be submitting on codePost:

∗ ChessSudoku.java

Do not submit any other files, especially .class files. Any deviation from these

requirements may lead to lost marks

• Please note that the classes you submit should be part of a package called finalproject.

• Starter code is provided for this project. Do not change any of the class names, file names,

method headers. You can add helper (i.e. private!) methods if you wish. Note also that

for this project, you are NOT allowed to import any other class (all import statements other

than the one provided in the starter code will be removed). Any failure to comply with

these rules will give you an automatic 0.

• The project shall be graded automatically. Requests to evaluate the project manually shall

not be entertained, so please make sure that you follow the instruction closely or your code

may fail to pass the automatic tests.

• Whenever you submit your files to codepost, you will see the results of some exposed tests.

These tests are a mini version of the tests we will be using to grade your work. If your code

fails those tests, it means that there is a mistake somewhere. Even if your code passes those

tests, it may still contain some errors. We will test your code on a much more challenging set

of examples. We highly encourage you to test your code thoroughly before submitting your

final version.

• You will automatically get 0 if your code does not compile.

• Failure to comply with any of these rules will be penalized. If anything is unclear, it is up to

you to clarify it by asking either directly a TA during office hours, or on the discussion board

on Piazza.

1

Learning Objectives

This project is meant for you to practice once again working with recursive algorithms. In particular,

you will learn about backtracking algorithms which at the base use the idea depth-first search on

search trees. The starter code provided for this project is not as extensive as in the past assignments.

This will leave you more freedom on how to go about implementing the tasks your code is required

to perform.

Introduction

A Sudoku is a Japanese logic puzzle which has been extremely popular for the past 20 years. In

classic Sudoku, the player has to fill a 9 by 9 grid using digits from 1 to 9 making sure that no digit

is repeated on any row, column or 3 by 3 box composing the grid. If you have never done so, I would

suggest you to try solving some Sudoku puzzles (you can find many here). As you might know,

many different variants of Sudoku exist. My personal favourite is Chess Sudoku which I discovered

when last summer I found myself binge watching a YouTube channel called Cracking the Cryptic

(by the way, I highly recommend the channel even if you think Sudoku is not for you. You’ll change

your mind!). A Chess Sudoku puzzle is a classic Sudoku puzzle with the addition of one or more of

the following chess inspired rules:

• Knight Rule: a digit must not appear a chess knight’s move away from itself. Knights in chess

move forming an L shape: either two squares vertically and one horizontally, or two squares

horizontally and one square vertically. See this figure for a graphical representation.

• King Rule: a digit must not be a King’s move away from itself. Which to the classical rules

of Sudoku only adds the fact that a digit cannot be a single diagonal move away from itself.

• Queen Rule: every 9 in the grid acts like a chess Queen and must not be in the same row/-

column/3x3 box or diagonal of any other 9.

For this project you will write a program that will attempt to solve Classical and Chess Sudoku

puzzles. The starter code contains a simple class representing a Sudoku puzzle. The class also

contains several methods that allow you to load a Sudoku grid from a txt file and display it on the

screen.

Your goal is to implement the method solve() which modifies the ChessSudoku object on which

it is call, by filling in the grid to obtain a solution.

Backtracking

There are many different ways you can write a program that solves Sudoku’s puzzles. A common

way to approach the problem is using a backtracking algorithm. Backtracking is a brute force

approach that consists in building a set of solutions incrementally. The idea is to use recursion to

build a solution step by step. In the usual scenario, we have different options at each step and we

simply make a decision. As soon as the algorithm realizes that the step taken led to a set of solutions

that would be invalid (i.e. they won’t satisfy the constraints of the problem), then it backtracks,

2

effectively eliminating all solutions that could be obtained by taking that last step. You can think

of this as if the set of all possible solutions is represented by the leaves of a tree where each internal

node represents a step taken toward a possible solution (i.e. a partial solve to the problem). Then

a backtracking algorithm would perform a depth-first search on this tree and as soon as it figures

out that the solutions obtained in a certain branch would be invalid, it simply discards that whole

branch and moves to the next one.

For example, when we begin to solve a problem we can think about starting at the root of a tree

where its children denoted the possible choices we have available. By choosing one of its children

(i.e. by making a choice) we take a step toward a certain sets of possible solutions (i.e. the leaves

that are reachable from that child). Other choices will then be available to us and we’ll keep taking

steps forward until we either reach a leaf (i.e. a solution) or an internal node which we know will not

lead to any valid solution. If we reach a valid solution, then our task might be over. On the other

hand, if we reach an invalid solution or an internal node that will not lead to any valid solution, we

take a step back and at the previous level of the tree we choose the next child.

Consider the following tree:

root

/ | \

A B C

/\ /\ /\

D E F G H I

The leaves denote the set of possible solutions to the problem. Let’s say that only G, H, and I are

valid solutions. Now, a backtracking algorithm would start from the root and visit the first child

(i.e. take a decision that represents a first step toward a solution). We might then already realize

that A would not lead to any valid solution. If that’s the case we would then backtrack, undoing

what we had done in the last step and getting back to the root node where we’ll then take the next

available choice that will lead us to node B. From B the next step will lead us to the leaf F which

does not represent a valid solution. We will then backtrack, undoing what we had done in the last

step and getting back to B where we can then take the next available choice. This will lead us to G

which happens to be a valid solution and hence we are done.

How can you apply this type of reasoning to solving a Sudoku? The idea would be the follow-

ing:

as long as there are empty cells in the grid

pick an empty cell and place a number in it

if a conflict occurs (i.e., at least one of the Sudoku rules is broken),

then remove that number and backtrack

if there are no conflicts, attempt to fill in the rest of the grid

if you were unable to fill the rest of the grid

then remove that number and backtrack

It is up to you to figure out how to code this idea into your program. I would highly suggest you

3

to spend some time solving a couple of Sudokus before starting to write your program. This will

allow you to better understand the problem at hand and think about possible steps you can take

to optimize your program. This project is much more open-ended than your previous assignments

and it leaves you the freedom to be more creative and try to bring together everything you have

learned throughout the semester.

Your Task

In the ChessSudoku class implement the method solve(). You can find additional information on

the method in the template code. Please feel free to add as many private helper methods/classes

as your see fit.

Testing and Evaluation

Your program will be tested on several classic Sudoku puzzles, as well as different variants of the

chess Sudoku puzzles.

Together with the template code, we provided you with a set of txt files representing different

Sudoku puzzles with different difficulties which you can use to test your program. Following the

same format you can create as many new puzzles as you like to further test your code. The puzzles

we’ll be using to grade your assignment will remain secret. Please note that the txt files should be

stored in the project folder of your program, and not the package folder, nor the src folder.

This is how we will evaluate your code:

+ 75% Your program finds a solution to 3x3 Sudoku puzzles in less than 10 seconds (assuming

they have a solution). The points awarded will be proportional to the number of puzzles from

the secret tests your code can solve.

+ 10% Your program find a solution to square puzzles up to 5x5 (assuming they have a solution).

+ 10% Your program has an additional feature that finds all possible solutions to a given puzzle.

This will involve continuing the search after the first solution is found (i.e., pretending that

solution doesn’t exist) to see if another solution can be found. All the solved Sudokus should

be correctly stored in the field named solutions.

last 5% The remaining 5% of the grade will be established based on your code’s ranking in a

tournament where each program will be given one minute to solve each Sudoku puzzle on our

computer. The ranking is established based on the number of Sudokus it succeeds at solving,

from a set of 10 problems ranging from very easy to very difficult.

4

学霸联盟

COMP 250 Winter 2021

posted: Friday, Apr. 16, 2021

due: Friday, Apr. 30, 2021 at 23:59

General Instructions

• Submission instructions

– Please note that the submission deadline for the final project is very strict. No sub-

missions will be accepted after the deadline.

– As always you can submit your code multiple times but only the latest submission will

be kept. We encourage you to submit a first version a few days before the deadline

(computer crashes do happen and codePost may be overloaded during rush hours).

– This is the file you should be submitting on codePost:

∗ ChessSudoku.java

Do not submit any other files, especially .class files. Any deviation from these

requirements may lead to lost marks

• Please note that the classes you submit should be part of a package called finalproject.

• Starter code is provided for this project. Do not change any of the class names, file names,

method headers. You can add helper (i.e. private!) methods if you wish. Note also that

for this project, you are NOT allowed to import any other class (all import statements other

than the one provided in the starter code will be removed). Any failure to comply with

these rules will give you an automatic 0.

• The project shall be graded automatically. Requests to evaluate the project manually shall

not be entertained, so please make sure that you follow the instruction closely or your code

may fail to pass the automatic tests.

• Whenever you submit your files to codepost, you will see the results of some exposed tests.

These tests are a mini version of the tests we will be using to grade your work. If your code

fails those tests, it means that there is a mistake somewhere. Even if your code passes those

tests, it may still contain some errors. We will test your code on a much more challenging set

of examples. We highly encourage you to test your code thoroughly before submitting your

final version.

• You will automatically get 0 if your code does not compile.

• Failure to comply with any of these rules will be penalized. If anything is unclear, it is up to

you to clarify it by asking either directly a TA during office hours, or on the discussion board

on Piazza.

1

Learning Objectives

This project is meant for you to practice once again working with recursive algorithms. In particular,

you will learn about backtracking algorithms which at the base use the idea depth-first search on

search trees. The starter code provided for this project is not as extensive as in the past assignments.

This will leave you more freedom on how to go about implementing the tasks your code is required

to perform.

Introduction

A Sudoku is a Japanese logic puzzle which has been extremely popular for the past 20 years. In

classic Sudoku, the player has to fill a 9 by 9 grid using digits from 1 to 9 making sure that no digit

is repeated on any row, column or 3 by 3 box composing the grid. If you have never done so, I would

suggest you to try solving some Sudoku puzzles (you can find many here). As you might know,

many different variants of Sudoku exist. My personal favourite is Chess Sudoku which I discovered

when last summer I found myself binge watching a YouTube channel called Cracking the Cryptic

(by the way, I highly recommend the channel even if you think Sudoku is not for you. You’ll change

your mind!). A Chess Sudoku puzzle is a classic Sudoku puzzle with the addition of one or more of

the following chess inspired rules:

• Knight Rule: a digit must not appear a chess knight’s move away from itself. Knights in chess

move forming an L shape: either two squares vertically and one horizontally, or two squares

horizontally and one square vertically. See this figure for a graphical representation.

• King Rule: a digit must not be a King’s move away from itself. Which to the classical rules

of Sudoku only adds the fact that a digit cannot be a single diagonal move away from itself.

• Queen Rule: every 9 in the grid acts like a chess Queen and must not be in the same row/-

column/3x3 box or diagonal of any other 9.

For this project you will write a program that will attempt to solve Classical and Chess Sudoku

puzzles. The starter code contains a simple class representing a Sudoku puzzle. The class also

contains several methods that allow you to load a Sudoku grid from a txt file and display it on the

screen.

Your goal is to implement the method solve() which modifies the ChessSudoku object on which

it is call, by filling in the grid to obtain a solution.

Backtracking

There are many different ways you can write a program that solves Sudoku’s puzzles. A common

way to approach the problem is using a backtracking algorithm. Backtracking is a brute force

approach that consists in building a set of solutions incrementally. The idea is to use recursion to

build a solution step by step. In the usual scenario, we have different options at each step and we

simply make a decision. As soon as the algorithm realizes that the step taken led to a set of solutions

that would be invalid (i.e. they won’t satisfy the constraints of the problem), then it backtracks,

2

effectively eliminating all solutions that could be obtained by taking that last step. You can think

of this as if the set of all possible solutions is represented by the leaves of a tree where each internal

node represents a step taken toward a possible solution (i.e. a partial solve to the problem). Then

a backtracking algorithm would perform a depth-first search on this tree and as soon as it figures

out that the solutions obtained in a certain branch would be invalid, it simply discards that whole

branch and moves to the next one.

For example, when we begin to solve a problem we can think about starting at the root of a tree

where its children denoted the possible choices we have available. By choosing one of its children

(i.e. by making a choice) we take a step toward a certain sets of possible solutions (i.e. the leaves

that are reachable from that child). Other choices will then be available to us and we’ll keep taking

steps forward until we either reach a leaf (i.e. a solution) or an internal node which we know will not

lead to any valid solution. If we reach a valid solution, then our task might be over. On the other

hand, if we reach an invalid solution or an internal node that will not lead to any valid solution, we

take a step back and at the previous level of the tree we choose the next child.

Consider the following tree:

root

/ | \

A B C

/\ /\ /\

D E F G H I

The leaves denote the set of possible solutions to the problem. Let’s say that only G, H, and I are

valid solutions. Now, a backtracking algorithm would start from the root and visit the first child

(i.e. take a decision that represents a first step toward a solution). We might then already realize

that A would not lead to any valid solution. If that’s the case we would then backtrack, undoing

what we had done in the last step and getting back to the root node where we’ll then take the next

available choice that will lead us to node B. From B the next step will lead us to the leaf F which

does not represent a valid solution. We will then backtrack, undoing what we had done in the last

step and getting back to B where we can then take the next available choice. This will lead us to G

which happens to be a valid solution and hence we are done.

How can you apply this type of reasoning to solving a Sudoku? The idea would be the follow-

ing:

as long as there are empty cells in the grid

pick an empty cell and place a number in it

if a conflict occurs (i.e., at least one of the Sudoku rules is broken),

then remove that number and backtrack

if there are no conflicts, attempt to fill in the rest of the grid

if you were unable to fill the rest of the grid

then remove that number and backtrack

It is up to you to figure out how to code this idea into your program. I would highly suggest you

3

to spend some time solving a couple of Sudokus before starting to write your program. This will

allow you to better understand the problem at hand and think about possible steps you can take

to optimize your program. This project is much more open-ended than your previous assignments

and it leaves you the freedom to be more creative and try to bring together everything you have

learned throughout the semester.

Your Task

In the ChessSudoku class implement the method solve(). You can find additional information on

the method in the template code. Please feel free to add as many private helper methods/classes

as your see fit.

Testing and Evaluation

Your program will be tested on several classic Sudoku puzzles, as well as different variants of the

chess Sudoku puzzles.

Together with the template code, we provided you with a set of txt files representing different

Sudoku puzzles with different difficulties which you can use to test your program. Following the

same format you can create as many new puzzles as you like to further test your code. The puzzles

we’ll be using to grade your assignment will remain secret. Please note that the txt files should be

stored in the project folder of your program, and not the package folder, nor the src folder.

This is how we will evaluate your code:

+ 75% Your program finds a solution to 3x3 Sudoku puzzles in less than 10 seconds (assuming

they have a solution). The points awarded will be proportional to the number of puzzles from

the secret tests your code can solve.

+ 10% Your program find a solution to square puzzles up to 5x5 (assuming they have a solution).

+ 10% Your program has an additional feature that finds all possible solutions to a given puzzle.

This will involve continuing the search after the first solution is found (i.e., pretending that

solution doesn’t exist) to see if another solution can be found. All the solved Sudokus should

be correctly stored in the field named solutions.

last 5% The remaining 5% of the grade will be established based on your code’s ranking in a

tournament where each program will be given one minute to solve each Sudoku puzzle on our

computer. The ranking is established based on the number of Sudokus it succeeds at solving,

from a set of 10 problems ranging from very easy to very difficult.

4

学霸联盟

- 留学生代写
- Python代写
- Java代写
- c/c++代写
- 数据库代写
- 算法代写
- 机器学习代写
- 数据挖掘代写
- 数据分析代写
- Android代写
- html代写
- 计算机网络代写
- 操作系统代写
- 计算机体系结构代写
- R代写
- 数学代写
- 金融作业代写
- 微观经济学代写
- 会计代写
- 统计代写
- 生物代写
- 物理代写
- 机械代写
- Assignment代写
- sql数据库代写
- analysis代写
- Haskell代写
- Linux代写
- Shell代写
- Diode Ideality Factor代写
- 宏观经济学代写
- 经济代写
- 计量经济代写
- math代写
- 金融统计代写
- 经济统计代写
- 概率论代写
- 代数代写
- 工程作业代写
- Databases代写
- 逻辑代写
- JavaScript代写
- Matlab代写
- Unity代写
- BigDate大数据代写
- 汇编代写
- stat代写
- scala代写
- OpenGL代写
- CS代写
- 程序代写
- 简答代写
- Excel代写
- Logisim代写
- 代码代写
- 手写题代写
- 电子工程代写
- 判断代写
- 论文代写
- stata代写
- witness代写
- statscloud代写
- 证明代写
- 非欧几何代写
- 理论代写
- http代写
- MySQL代写
- PHP代写
- 计算代写
- 考试代写
- 博弈论代写
- 英语代写
- essay代写
- 不限代写
- lingo代写
- 线性代数代写
- 文本处理代写
- 商科代写
- visual studio代写
- 光谱分析代写
- report代写
- GCP代写
- 无代写
- 电力系统代写
- refinitiv eikon代写
- 运筹学代写
- simulink代写
- 单片机代写
- GAMS代写
- 人力资源代写
- 报告代写
- SQLAlchemy代写
- Stufio代写
- sklearn代写
- 计算机架构代写
- 贝叶斯代写
- 以太坊代写
- 计算证明代写
- prolog代写
- 交互设计代写
- mips代写
- css代写
- 云计算代写
- dafny代写
- quiz考试代写
- js代写
- 密码学代写
- ml代写
- 水利工程基础代写
- 经济管理代写
- Rmarkdown代写
- 电路代写
- 质量管理画图代写
- sas代写
- 金融数学代写
- processing代写
- 预测分析代写
- 机械力学代写
- vhdl代写
- solidworks代写
- 不涉及代写
- 计算分析代写
- Netlogo代写
- openbugs代写
- 土木代写
- 国际金融专题代写
- 离散数学代写
- openssl代写
- 化学材料代写
- eview代写
- nlp代写
- Assembly language代写
- gproms代写
- studio代写
- robot analyse代写
- pytorch代写
- 证明题代写
- latex代写
- coq代写
- 市场营销论文代写
- 人力资论文代写
- weka代写
- 英文代写
- Minitab代写
- 航空代写
- webots代写
- Advanced Management Accounting代写
- Lunix代写
- 云基础代写
- 有限状态过程代写
- aws代写
- AI代写
- 图灵机代写
- Sociology代写
- 分析代写
- 经济开发代写
- Data代写
- jupyter代写
- 通信考试代写
- 网络安全代写
- 固体力学代写
- spss代写
- 无编程代写
- react代写
- Ocaml代写
- 期货期权代写
- Scheme代写
- 数学统计代写
- 信息安全代写
- Bloomberg代写
- 残疾与创新设计代写
- 历史代写
- 理论题代写
- cpu代写
- 计量代写
- Xpress-IVE代写
- 微积分代写
- 材料学代写
- 代写
- 会计信息系统代写
- 凸优化代写
- 投资代写
- F#代写
- C#代写
- arm代写
- 伪代码代写
- 白话代写
- IC集成电路代写
- reasoning代写
- agents代写
- 精算代写
- opencl代写
- Perl代写
- 图像处理代写
- 工程电磁场代写
- 时间序列代写
- 数据结构算法代写
- 网络基础代写
- 画图代写
- Marie代写
- ASP代写
- EViews代写
- Interval Temporal Logic代写
- ccgarch代写
- rmgarch代写
- jmp代写
- 选择填空代写
- mathematics代写
- winbugs代写
- maya代写
- Directx代写
- PPT代写
- 可视化代写
- 工程材料代写
- 环境代写
- abaqus代写
- 投资组合代写
- 选择题代写
- openmp.c代写
- cuda.cu代写
- 传感器基础代写
- 区块链比特币代写
- 土壤固结代写
- 电气代写
- 电子设计代写
- 主观题代写
- 金融微积代写
- ajax代写
- Risk theory代写
- tcp代写
- tableau代写
- mylab代写
- research paper代写
- 手写代写
- 管理代写
- paper代写
- 毕设代写
- 衍生品代写
- 学术论文代写
- 计算画图代写
- SPIM汇编代写
- 演讲稿代写
- 金融实证代写
- 环境化学代写
- 通信代写
- 股权市场代写
- 计算机逻辑代写
- Microsoft Visio代写
- 业务流程管理代写
- Spark代写
- USYD代写
- 数值分析代写
- 有限元代写
- 抽代代写
- 不限定代写
- IOS代写
- scikit-learn代写
- ts angular代写
- sml代写
- 管理决策分析代写
- vba代写
- 墨大代写
- erlang代写
- Azure代写
- 粒子物理代写
- 编译器代写
- socket代写
- 商业分析代写
- 财务报表分析代写
- Machine Learning代写
- 国际贸易代写
- code代写
- 流体力学代写
- 辅导代写
- 设计代写
- marketing代写
- web代写
- 计算机代写
- verilog代写
- 心理学代写
- 线性回归代写
- 高级数据分析代写
- clingo代写
- Mplab代写
- coventorware代写
- creo代写
- nosql代写
- 供应链代写
- uml代写
- 数字业务技术代写
- 数字业务管理代写
- 结构分析代写
- tf-idf代写
- 地理代写
- financial modeling代写
- quantlib代写
- 电力电子元件代写
- atenda 2D代写
- 宏观代写
- 媒体代写
- 政治代写
- 化学代写
- 随机过程代写
- self attension算法代写
- arm assembly代写
- wireshark代写
- openCV代写
- Uncertainty Quantificatio代写
- prolong代写
- IPYthon代写
- Digital system design 代写
- julia代写
- Advanced Geotechnical Engineering代写
- 回答问题代写
- junit代写
- solidty代写
- maple代写
- 光电技术代写
- 网页代写
- 网络分析代写
- ENVI代写
- gimp代写
- sfml代写
- 社会学代写
- simulationX solidwork代写
- unity 3D代写
- ansys代写
- react native代写
- Alloy代写
- Applied Matrix代写
- JMP PRO代写
- 微观代写
- 人类健康代写
- 市场代写
- proposal代写
- 软件代写
- 信息检索代写
- 商法代写
- 信号代写
- pycharm代写
- 金融风险管理代写
- 数据可视化代写
- fashion代写
- 加拿大代写
- 经济学代写
- Behavioural Finance代写
- cytoscape代写
- 推荐代写
- 金融经济代写
- optimization代写
- alteryxy代写
- tabluea代写
- sas viya代写
- ads代写
- 实时系统代写
- 药剂学代写
- os代写
- Mathematica代写
- Xcode代写
- Swift代写
- rattle代写
- 人工智能代写
- 流体代写
- 结构力学代写
- Communications代写
- 动物学代写
- 问答代写
- MiKTEX代写
- 图论代写
- 数据科学代写
- 计算机安全代写
- 日本历史代写
- gis代写
- rs代写
- 语言代写
- 电学代写
- flutter代写
- drat代写
- 澳洲代写
- 医药代写
- ox代写
- 营销代写
- pddl代写
- 工程项目代写
- archi代写
- Propositional Logic代写
- 国际财务管理代写
- 高宏代写
- 模型代写
- 润色代写
- 营养学论文代写
- 热力学代写
- Acct代写
- Data Synthesis代写
- 翻译代写
- 公司法代写
- 管理学代写
- 建筑学代写
- 生理课程代写
- 动画代写
- 高数代写
- 内嵌式代写
- Truffles代写
- 地质学代写