Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

IA160-3-FY - Project 2 1 University of Essex – Essex Pathways Department Year Zero Programmes – Coursework Assessment Academic Year – XXXXXXXXXX IA160-3-FY Computer Programming Project 2 Assignment...

1 answer below »
IA160-3-FY - Project 2
1

University of Essex – Essex Pathways Department
Year Zero Programmes – Coursework Assessment
Academic Year – XXXXXXXXXX

IA160-3-FY Computer Programming
Project 2 Assignment
Magic Square Puzzle Board Validator

Assignment weighting: 40% of overall coursework for IA160.


Assignment Task:

You are required to solve and write Python code for the task below; and produce a written report to
describe and analyse the problem you are solving, explain your solution to the problem, and detail
how you have tested and evaluated your solution.

You must use Python version 3 for this assignment; submissions using any other programming
language or Python version will not be marked and could result in a mark of zero for this assignment.


Task (Magic Square Puzzle):

• Write a Python program to validate a given Magic Square puzzle board.

• Background:

o A typical Magic Square is an n x n square grid filled with integers 1 to n2.

o The integers should be placed in the grid so that each row, each column, and each of
the two diagonals all add up to the same value.

o Conditions state that no single integer can be used more than once in the grid.
o The grid can vary in size, but must be a square formation (3x3, 4x4, 5x5, etc.).








15 15
15
15
15
XXXXXXXXXX
9 5 1
4 3 8
2 7 6
2

Examples of some valid Magic Square puzzle boards:



















• The puzzle boards will be supplied to the program in the form of a simple text file, for
example:



• The program should prompt the user for the filename of a text file to open – some Python
e
or handling should be used in case the user enters the name of a file that does not exist.
• The program should read the contents of the given text file and store this in a suitable Python
data structure.
• Appropriate validation should be in place to ensure the supplied file contains a complete n x n
square grid of digits, and ensure the digits are all integers in the range 1 to n2; a suitable e
or
message should be returned where necessary.
• Assuming a suitable n x n square grid of integers is successfully loaded into the chosen data
structure, further checks should then be performed to ensure that the sums of each row, each
column, and each of the two diagonals are all equal.
• If any e
ors are detected in the puzzle board then details of these e
ors should be given to
the user.
• If the puzzle board passes all the validation checks, then it should be written into a new text
file using the same format as the original input file (see the example text files above) – the
name for this new text file should be the original filename entered by the user prefixed with
“VALID_”.
• You should try to make your Python program as efficient as you can – consider segmenting
your code into functions where appropriate for particular tasks.
8 1 6
3 5 7
4 9 2
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
3

Report:

• Produce a written report in a Microsoft Word document (or similar) to describe your program.

• The report must contain the following sections:
o Introduction – this should contain some background information, generally summarise the
problem being solved in this task and demonstrate a clear understanding of the problems.
o Solution Explanation – this is the main body of your report where you should describe
your design and solution to the problem/task outlined in the introduction, and explain any
key aspects to the program. You can also use this section to explain your design rationale
for certain parts of your code (i.e. why have you done something in a certain way).
o Testing – explain how you have tested your program, and if appropriate give some sample
data and output examples from the program. There should be evidence of your program
eing tested given either in this section or in the appendix and refe
ed to from this
section.
o Conclusion – use this section to evaluate your work (i.e. your solution to the problem
described in the introduction), for example, what has worked well, what would you like to
change next time.
o Appendix – you should copy and paste your entire program code into this final section of
the report.
• Please note, any code pasted into the report (including the appendix) should use the Courier
New (or a similar fixed-width) font to distinguish it from any other text; screenshots must not be
used for source code.

• If you have used any materials beyond the lecture slides and lab notes (e.g. programming
textbooks or websites) then these must be cited accordingly using the IEEE referencing style.
• The word count for the report is ~2000 words ±10% (excluding contents page, code segments,
program output, references, and appendix).


Deliverables:

• ‘Feedback Matters’ checklist (assignment coversheet) completed with your reflections on the
feedback received for the previous assignment
• Python script file for the task
• Report – Microsoft Word document (or similar)


Submission instructions:

• Submissions should be made online using the University electronic submission service
(FASer) – see your student handbook for details.
• You are not required to submit a watermarked and/or printed hardcopy of your work.
• You are reminded that the University has a zero tolerance policy for late submissions –
again, see your student handbook for details.
• You may also be asked to explain your solution to the task and demonstrate your program to
your tutor.



4

Warning against plagiarism:

• This assignment is an individual task and not a group activity.
• You must not copy any work or ideas from another student.
• Please be aware that it is also an academic offence to complete a piece of work for another
student; or to knowingly allow another student to copy your work or ideas.
• Ensure that any sources you use throughout the assignment are co
ectly referenced and
included in your bibliography
eferences section at the end of your report.
• For further guidance and advise on plagiarism please refer to this link:
http:
www.essex.ac.uk/plagiarism/


Assignment deadline: Tuesday 17th March 2020 (University week 25)
The time for all on-line submissions is on or before 13.00.


Assignment feedback: Will be made through FASer; you will be emailed once this is available.


Subject Support Contact: Dr. Ian Mothersole – XXXXXXXXXX
Edward Longford – XXXXXXXXXX
Academic support hours are available on the IA160 Moodle site.


RAD Skills Contact: Chris Eustace – XXXXXXXXXX
Paul No
is – no
XXXXXXXXXX
Academic support hours are available on the IA193 Moodle site.



5

Marking Scheme

Tasks Marking Criteria
Marks %
Subject:

Program /
code and
documentation
Program can successfully read the
puzzle board text file into a suitable
data structure.
Program should prompt the user for a
filename and have good e
or handling
in case a file does not exist.
Cannot read a text file:
Text file contents read successfully:
0
1-2
No E
or handling:
E
or handling in place for filenames:
0
1-2
Inco
ect/inappropriate data structure:
Data structure functional but not efficient:
Good/co
ect data structure used:
0
1-2
3-6
Total: 10
General validation of the puzzle board.
Further tests to ensure puzzle board
meets the appropriate rules for the
puzzle.
No general validation:
Some general validation:
Good/complete validation:
0
1-5
6-10
No further tests of rules for the puzzle:
Some testing of rules for the puzzle:
Extensive testing of rules for the puzzle:
0
1-10
11-15
Total: 25
Detailed reporting of any e
ors found in
the puzzle board.
Valid puzzle board written to text file
co
ectly (using the co
ect filename and
the same formatting as the original file).
No e
or reporting:
E
or report given, but not detailed:
Full and detailed e
or report:
0
1-10
11-15
Not written to a file:
Written to a file but contains some e
ors:
Co
ectly written to a file:
0
1-2
3-5
Total: 20
Code must be neat and well structured
and include suitable comments where
appropriate.
Program should be efficiently written
and efficiently designed.
The solution must be thoroughly
explained in the report; and clear
evidence of all testing also must be
given in the report.
Code is poorly structured/not consistent
and/or difficult to follow:
Code is neat and well structured:

0-2
3-5
Poor and/or inefficient program design:
Good and efficient program design:
Excellent overall program design:
0
1-5
6-10
Poor solution explanation and testing:
Good solution explanation and testing:
Excellent solution explanation and testing:
0
1-5
6-10
Total: 25
Research and
Academic
Development
Skills:

Report
The report must be written in a suitable
academic style (structure and
language). Make
Answered Same Day Mar 09, 2021

Solution

Mohd answered on Mar 10 2021
155 Votes
Solution/3X3.txt
8 1 6
3 5 7
4 9 2
Solution/4X4.txt
4 14 15 1
9 7 6 12
5 11 10 8
16 2 3 13
Solution/5X5.txt
23 6 19 2 15
4 12 25 8 16
10 18 1 14 22
11 24 7 20 3
17 5 13 21 9
Solution/6X6.txt
6 32 3 34 35 1
7 11 27 28 8 30
19 14 16 15 23 24
18 20 22 21 17 13
25 29 10 9 26 12
36 5 33 4 2 31
Solution/MagicSquarePuzzleBoardValidator.py
import glob, os
from itertools import islice
os.chdir(".")
fileName = input("Enter File name: ")
checkFile = False
#check given file exist or not
for file in glob.glob("*.txt"):
if fileName == file:
checkFile = True

eak
count = 0
checkSquare = False
checkNumber = False
itemList = []
checkDuplicateNumber = False
if checkFile == True:
f = open(fileName, 'r')
#count number of lines in the given file
while True:
line = f.readline()
if not line:

eak
count += 1
f.close()
#check given file contains square or not, and check number should betwee...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here