Assignment 2COMP9021, Session 1, 20181 General presentationYou will design and implement a program that willcheck whether some numbers, stored in a le, represent a particular coding of a frieze, and{ either display the period of the pattern of the frieze and the transformations that keep itinvariant, based on a result that classi es friezes into 7 groups of symmetries,{ or output some Latex code in a le, from which a pictorial representation of the frieze can beproduced.The representation of a frieze is based on a coding with numbers in the range 0 . . .15, each such numbern being associated with a particular point p such thatif the rightmost digit of the representation of n in base 2 is equal to 1 then p is to be connected toits northern neighbour:if the second rightmost digit of the representation of n in base 2 is equal to 1 then p is to beconnected to its north-eastern neighbour:if the third rightmost digit of the representation of n in base 2 is equal to 1 then p is to be connectedto its eastern neighbour:if the fourth rightmost digit of the representation of n in base 2 is equal to 1 then p is to beconnected to its south-eastern neighbour:12 Examples2.1 First exampleThe le frieze_1.txt has the following contents.4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 00 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 00 0 0 0 4 4 1 5 4 4 4 4 8 0 0 0 0 0 0 4 4 1 5 4 4 4 4 8 0 0 00 0 0 2 0 0 5 1 0 0 0 0 0 8 0 0 0 0 2 0 0 5 1 0 0 0 0 0 8 0 00 0 2 0 0 0 0 0 0 0 0 0 0 0 8 0 0 2 0 0 0 0 0 0 0 0 0 0 0 8 00 6 4 4 4 4 4 4 4 4 4 4 4 4 4 0 6 4 4 4 4 4 4 4 4 4 4 4 4 4 01 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 11 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 11 1 0 0 0 0 0 0 4 4 4 12 4 4 4 1 1 0 0 0 0 0 0 4 4 4 12 4 4 4 11 1 0 4 4 0 0 0 1 2 0 0 8 1 0 1 1 0 4 4 0 0 0 1 2 0 0 8 1 0 11 1 0 5 5 1 0 0 3 0 0 0 0 1 0 1 1 0 5 5 1 0 0 3 0 0 0 0 1 0 11 1 0 5 5 1 0 0 5 4 4 4 4 1 0 1 1 0 5 5 1 0 0 5 4 4 4 4 1 0 11 1 0 1 0 1 0 0 0 0 0 0 0 0 0 1 1 0 1 0 1 0 0 0 0 0 0 0 0 0 11 1 0 1 0 1 0 0 0 0 0 0 0 0 0 1 1 0 1 0 1 0 0 0 0 0 0 0 0 0 11 5 4 5 4 5 4 4 4 4 4 4 4 4 4 1 5 4 5 4 5 4 4 4 4 4 4 4 4 4 14 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 0Here is a possible interaction:$ python3Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28)...>>> from frieze import *>>> frieze = Frieze(’frieze_1.txt’)>>> frieze.analyse()Pattern is a frieze of period 15 that is invariant under translation only.>>> frieze.display()The e ect of executing frieze.display() is to produce a le named frieze_1.tex that can be givenas argument to pdflatex to produce a le named frieze_1.pdf that views as follows.22.2 Second exampleThe le frieze_2.txt has the following contents.4 4 4 4 4 4 4 4 4 4 12 4 4 4 4 4 4 4 4 4 4 4 12 4 4 4 4 4 4 4 4 4 4 4 12 4 4 4 4 4 4 4 4 4 4 4 12 4 00 0 0 4 8 0 0 0 3 1 1 1 0 0 0 4 8 0 0 0 3 1 1 1 0 0 0 4 8 0 0 0 3 1 1 1 0 0 0 4 8 0 0 0 3 1 1 1 00 0 2 0 0 0 0 0 0 1 1 0 0 0 2 0 0 0 0 0 0 1 1 0 0 0 2 0 0 0 0 0 0 1 1 0 0 0 2 0 0 0 0 0 0 1 1 0 01 0 9 0 0 1 0 1 0 1 1 0 1 0 9 0 0 1 0 1 0 1 1 0 1 0 9 0 0 1 0 1 0 1 1 0 1 0 9 0 0 1 0 1 0 1 1 0 14 0 0 4 2 0 4 4 8 1 1 4 4 0 0 4 2 0 4 4 8 1 1 4 4 0 0 4 2 0 4 4 8 1 1 4 4 0 0 4 2 0 4 4 8 1 1 4 08 1 0 0 0 0 1 0 0 1 3 0 8 1 0 0 0 0 1 0 0 1 3 0 8 1 0 0 0 0 1 0 0 1 3 0 8 1 0 0 0 0 1 0 0 1 3 0 01 1 0 4 0 0 3 1 0 0 0 0 1 1 0 4 0 0 3 1 0 0 0 0 1 1 0 4 0 0 3 1 0 0 0 0 1 1 0 4 0 0 3 1 0 0 0 0 11 0 0 5 1 0 0 1 0 4 0 0 1 0 0 5 1 0 0 1 0 4 0 0 1 0 0 5 1 0 0 1 0 4 0 0 1 0 0 5 1 0 0 1 0 4 0 0 11 4 4 0 4 4 8 1 0 1 1 0 1 4 4 0 4 4 8 1 0 1 1 0 1 4 4 0 4 4 8 1 0 1 1 0 1 4 4 0 4 4 8 1 0 1 1 0 13 0 8 1 1 0 0 1 0 1 1 0 3 0 8 1 1 0 0 1 0 1 1 0 3 0 8 1 1 0 0 1 0 1 1 0 3 0 8 1 1 0 0 1 0 1 1 0 10 0 1 1 3 1 0 0 4 1 5 0 0 0 1 1 3 1 0 0 4 1 5 0 0 0 1 1 3 1 0 0 4 1 5 0 0 0 1 1 3 1 0 0 4 1 5 0 00 0 1 0 8 1 0 0 1 0 0 1 0 0 1 0 8 1 0 0 1 0 0 1 0 0 1 0 8 1 0 0 1 0 0 1 0 0 1 0 8 1 0 0 1 0 0 1 04 4 7 5 5 5 4 4 5 4 4 5 4 4 7 5 5 5 4 4 5 4 4 5 4 4 7 5 5 5 4 4 5 4 4 5 4 4 7 5 5 5 4 4 5 4 4 5 0Here is a possible interaction:$ python3Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28)...>>> from frieze import *>>> frieze = Frieze(’frieze_2.txt’)>>> frieze.analyse()Pattern is a frieze of period 12 that is invariant under translationand vertical reflection only.>>> frieze.display()The e ect of executing frieze.display() is to produce a le named frieze_2.tex that can be givenas argument to pdflatex to produce a le named frieze_2.pdf that views as follows.32.3 Third exampleThe le frieze_3.txt has the following contents.12 4 12 12 4 12 12 4 12 12 4 12 12 4 12 12 4 12 12 4 12 12 4 12 12 4 12 12 4 12 12 4 12 12 4 12 12 4 12 12 4 12 12 4 12 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 09 5 8 9 5 8 9 5 8 9 5 8 9 5 8 9 5 8 9 5 8 9 5 8 9 5 8 9 5 8 9 5 8 9 5 8 9 5 8 9 5 8 9 5 8 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 02 4 2 2 4 2 2 4 2 2 4 2 2 4 2 2 4 2 2 4 2 2 4 2 2 4 2 2 4 2 2 4 2 2 4 2 2 4 2 2 4 2 2 4 2 01 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 16 4 6 6 4 6 6 4 6 6 4 6 6 4 6 6 4 6 6 4 6 6 4 6 6 4 6 6 4 6 6 4 6 6 4 6 6 4 6 6 4 6 6 4 6 0Here is a possible interaction:$ python3Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28)...>>> from frieze import *>>> frieze = Frieze(’frieze_3.txt’)>>> frieze.analyse()Pattern is a frieze of period 3 that is invariant under translationand horizontal reflection only.>>> frieze.display()The e ect of executing frieze.display() is to produce a le named frieze_3.tex that can be givenas argument to pdflatex to produce a le named frieze_3.pdf that views as follows.42.4 Fourth exampleThe le frieze_4.txt has the following contents.4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 00 5 0 0 5 0 0 5 0 0 5 0 0 5 0 0 5 0 0 5 0 0 5 0 0 5 0 0 5 0 0 5 0 0 5 0 0 5 0 0 5 0 04 0 5 4 4 1 4 0 5 4 4 1 4 0 5 4 4 1 4 0 5 4 4 1 4 0 5 4 4 1 4 0 5 4 4 1 4 0 5 4 4 1 05 1 4 5 4 0 5 1 4 5 4 0 5 1 4 5 4 0 5 1 4 5 4 0 5 1 4 5 4 0 5 1 4 5 4 0 5 1 4 5 4 0 10 4 1 0 4 1 0 4 1 0 4 1 0 4 1 0 4 1 0 4 1 0 4 1 0 4 1 0 4 1 0 4 1 0 4 1 0 4 1 0 4 1 00 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 00 5 0 0 5 0 0 5 0 0 5 0 0 5 0 0 5 0 0 5 0 0 5 0 0 5 0 0 5 0 0 5 0 0 5 0 0 5 0 0 5 0 04 4 1 4 0 5 4 4 1 4 0 5 4 4 1 4 0 5 4 4 1 4 0 5 4 4 1 4 0 5 4 4 1 4 0 5 4 4 1 4 0 5 05 4 0 5 1 4 5 4 0 5 1 4 5 4 0 5 1 4 5 4 0 5 1 4 5 4 0 5 1 4 5 4 0 5 1 4 5 4 0 5 1 4 10 4 1 0 4 1 0 4 1 0 4 1 0 4 1 0 4 1 0 4 1 0 4 1 0 4 1 0 4 1 0 4 1 0 4 1 0 4 1 0 4 1 04 5 4 4 5 4 4 5 4 4 5 4 4 5 4 4 5 4 4 5 4 4 5 4 4 5 4 4 5 4 4 5 4 4 5 4 4 5 4 4 5 4 0Here is a possible interaction:$ python3Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28)...>>> from frieze import *>>> frieze = Frieze(’frieze_4.txt’)>>> frieze.analyse()Pattern is a frieze of period 6 that is invariant under translationand glided horizontal reflection only.>>> frieze.display()The e ect of executing frieze.display() is to produce a le named frieze_4.tex that can be givenas argument to pdflatex to produce a le named frieze_4.pdf that views as follows.52.5 Fifth exampleThe le frieze_5.txt has the following contents.4 4 4 4 4 4 12 4 4 4 4 4 4 4 12 4 4 4 4 4 4 4 12 4 4 4 4 4 4 4 12 4 4 4 4 4 4 4 12 4 4 4 4 4 4 4 12 4 00 4 1 0 0 2 0 8 0 4 1 0 0 2 0 8 0 4 1 0 0 2 0 8 0 4 1 0 0 2 0 8 0 4 1 0 0 2 0 8 0 4 1 0 0 2 0 8 010 0 0 0 2 0 0 0 10 0 0 0 2 0 0 0 10 0 0 0 2 0 0 0 10 0 0 0 2 0 0 0 10 0 0 0 2 0 0 0 10 0 0 0 2 0 0 0 00 8 0 2 0 0 4 2 0 8 0 2 0 0 4 2 0 8 0 2 0 0 4 2 0 8 0 2 0 0 4 2 0 8 0 2 0 0 4 2 0 8 0 2 0 0 4 2 04 4 6 4 4 4 5 4 4 4 6 4 4 4 5 4 4 4 6 4 4 4 5 4 4 4 6 4 4 4 5 4 4 4 6 4 4 4 5 4 4 4 6 4 4 4 5 4 0Here is a possible interaction:$ python3Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28)...>>> from frieze import *>>> frieze = Frieze(’frieze_5.txt’)>>> frieze.analyse()Pattern is a frieze of period 8 that is invariant under translationand rotation only.>>> frieze.display()The e ect of executing frieze.display() is to produce a le named frieze_5.tex that can be givenas argument to pdflatex to produce a le named frieze_5.pdf that views as follows.62.6 Sixth exampleThe le frieze_6.txt has the following contents.4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 04 0 4 4 4 0 4 4 4 0 4 4 4 0 4 4 4 0 4 4 4 0 4 4 4 0 4 4 4 0 4 4 4 0 4 4 4 0 4 4 00 1 1 4 0 1 1 4 0 1 1 4 0 1 1 4 0 1 1 4 0 1 1 4 0 1 1 4 0 1 1 4 0 1 1 4 0 1 1 4 01 5 1 1 1 5 1 1 1 5 1 1 1 5 1 1 1 5 1 1 1 5 1 1 1 5 1 1 1 5 1 1 1 5 1 1 1 5 1 1 15 4 4 1 5 4 4 1 5 4 4 1 5 4 4 1 5 4 4 1 5 4 4 1 5 4 4 1 5 4 4 1 5 4 4 1 5 4 4 1 14 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 0Here is a possible inte代写Python编程、Python编程作业帮做、调试Python作业、Python General presentatiraction:$ python3Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28)...>>> from frieze import *>>> frieze = Frieze(’frieze_6.txt’)>>> frieze.analyse()Pattern is a frieze of period 4 that is invariant under translation,glided horizontal and vertical reflections, and rotation only.>>> frieze.display()The e ect of executing frieze.display() is to produce a le named frieze_6.tex that can be givenas argument to pdflatex to produce a le named frieze_6.pdf that views as follows.72.7 Seventh exampleThe le frieze_7.txt has the following contents.4 4 12 4 4 4 12 4 4 4 12 4 4 4 12 4 4 4 12 4 4 4 12 4 00 2 0 8 0 2 0 8 0 2 0 8 0 2 0 8 0 2 0 8 0 2 0 8 010 0 8 0 10 0 8 0 10 0 8 0 10 0 8 0 10 0 8 0 10 0 8 0 00 2 0 2 0 2 0 2 0 2 0 2 0 2 0 2 0 2 0 2 0 2 0 2 00 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 00 9 0 9 0 9 0 9 0 9 0 9 0 9 0 9 0 9 0 9 0 9 0 9 010 0 2 0 10 0 2 0 10 0 2 0 10 0 2 0 10 0 2 0 10 0 2 0 00 8 0 2 0 8 0 2 0 8 0 2 0 8 0 2 0 8 0 2 0 8 0 2 04 4 6 4 4 4 6 4 4 4 6 4 4 4 6 4 4 4 6 4 4 4 6 4 0Here is a possible interaction:$ python3Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28)...>>> from frieze import *>>> frieze = Frieze(’frieze_7.txt’)>>> frieze.analyse()Pattern is a frieze of period 4 that is invariant under translation,horizontal and vertical reflections, and rotation only.>>> frieze.display()The e ect of executing frieze.display() is to produce a le named frieze_7.tex that can be givenas argument to pdflatex to produce a le named frieze_7.pdf that views as follows.83 Detailed description3.1 InputThe input is expected to consist of height + 1 lines of length + 1 numbers in f0;:::;15g, where lengthis at least equal to 4 and at most equal to 50 and height is at least equal to 2 and at most equal to 16,with possibly lines consisting of spaces only that will be ignored and with possibly spaces anywhere onthe lines with numbers. The xth number n of the yth line, with 0 x length and 0 y height,is to be associated with a point situated x? 0:2 cm to the right and y? 0.2 cm below an origin,is to be connected to the point 0.2 cm above if the rightmost digit of n is 1,is to be connected to the point 0.2 cm above and 0.2 cm to the right if the second rightmost digitof n is 1,is to be connected to the point 0.2 cm to the right if the third rightmost digit of n is 1, andis to be connected to the point 0.2 cm to the right and 0.2 cm below if the fourth rightmost digitof n is 1.To qualify as a frieze, the input is further constrained to t in a rectangle of length length? 0:2 cm andof height heigth? 0:2 cm, with horizontal lines of length length at the top and at the bottom, identicalvertical borders at both ends, no crossing segments connecting pairs of neighbours inside the rectangle,and a pattern of integral period at least equal to 2 that is fully repeated at least twice in the horizontaldimension.3.2 OutputConsider executing from the Python prompt the statement from frieze import * followed by thestatement frieze = Frieze(some_filename). In case some_filename does not exit in the workingdirectory, then Python will raise a FileNotFoundError exception, that does not need to be caught.Assume that some_filename does exit (in the working directory). If the input is incorrect in that itdoes not contain only numbers in f0;:::;15g besides spaces, or in that it contains either two few or toomany lines of numbers, or in that some line of numbers contains too many or two few numbers, or inthat two of its lines of numbers do not contain the same number of numbers, then the e ect of executingfrieze = Frieze(some_filename) should be to generate a FriezeError exception that readsTraceback (most recent call last):...frieze.FriezeError: Incorrect input.If the previous conditions hold but the further conditions spelled out above for the input to qualify as afrieze do not hold, then the e ect of executing frieze = Frieze(some_filename) should be to generatea FriezeError exception that reads9Traceback (most recent call last):...frieze.FriezeError: Input does not represent a frieze.If the input is correct and represents a frieze, then executing frieze = Frieze(some_filename) followedby frieze.analyse() should have the e ect of outputting one or two lines that readPattern is a frieze of period N that is invariant under translation only.orPattern is a frieze of period N that is invariant under translationand vertical reflection only.orPattern is a frieze of period N that is invariant under translationand horizontal reflection only.orPattern is a frieze of period N that is invariant under translationand glided horizontal reflection only.orPattern is a frieze of period N that is invariant under translationand rotation only.orPattern is a frieze of period N that is invariant under translation,glided horizontal and vertical reflections, and rotation only.orPattern is a frieze of period N that is invariant under translation,horizontal and vertical reflections, and rotation only.with N an appropriate integer at least equal to 2.These 7 possible outputs are based on a mathematical result on the classi cation of friezes that listsall possible complete lists of symmetries that leave a frieze invariant under an isometry (that is, atransformation that does not alter the distance between any two points). These possible lists involve 5symmetries.10Translation by period; of course, any frieze is invariant under this symmetry.Vertical re ection about some vertical line; that line does not necessarily delimit the pattern nordoes it necessarily go through its middle (these conditions are actually equivalent).Horizontal re ection about the line that goes through the middle of the frieze.Glided horizontal re ection, that is, horizontal re ection about the line that goes through themiddle of the frieze and translation by half the period of the resulting lower half of the frieze.Rotation around some point situated on the horizontal line that goes through the middle of thefrieze; this is equivalent to horizontal refection combined with vertical re ection.Pay attention to the expected format, including spaces.If the input is correct and represents a frieze, then executing frieze = Frieze(some_filename) followedby frieze.display() should have the e ect of producing a le named some_filename.tex that can begiven as argument to pdflatex to generate a le named some_filename.pdf. The provided exampleswill show you what some_filename.tex should contain. Segments are drawn in purple with a singledraw command for each longest segment,starting with the vertical segments, from the topmost leftmost one to the bottommost rightmostone with the leftmost ones rst,followed by the segments that go from north west to south east, from the topmost leftmost one tothe bottommost rightmost one with the topmost ones rst,followed by the segments that go from west to east, from the topmost leftmost one to the bottom-most rightmost one with the topmost ones rst,followed by the segments that go from the south west to the north east, from the topmost leftmostone to the bottommost rightmost one with the topmost ones rst.Pay attention to the expected format, including spaces and blank lines. Lines that start with % arecomments; there are 4 such lines, that have to be present even when there is no item to be displayed ofthe kind described by the comment. The output of your program redirected to a le will be comparedwith the expected output saved in a le (of a di erent name of course) using the diff command. Foryour program to pass the associated test, diff should silently exit, which requires that the contents ofboth les be absolutely identical, character for character, including spaces and blank lines. Check yourprogram on the provided examples using the associated .tex les, renaming them as they have the namesof the les expected to be generated by your program.4 Assessment and submission4.1 SubmissionYour program will be stored in a le which has to be named frieze.py. Your code can be submittedmore than once on Ed; the last version and only the last version will be run, tested and marked. Yourassignment is due by May 27, 11:59pm.114.2 AssessmentThe automarking script. will let each both assessed methods of your program run for 30 seconds. Stillyou should not take advantage of this and strive for a solution that gives an immediate output.Late assignments will be penalised: the mark for a late submission will be the minimum of the awardedmark and 10 minus the number of full and partial days that have elapsed from the due date.4.3 Reminder on plagiarism policyYou are permitted, indeed encouraged, to discuss ways to solve the assignment with other people. Suchdiscussions must be in terms of algorithms, not code. But you must implement the solution on yourown. Submissions are routinely scanned for similarities that occur when students copy and modify otherpeople’s work, or work very closely together on a single implementation. Severe penalties apply.转自:http://ass.3daixie.com/2018052758777276.html
讲解:Python、Python、Python、Python General presentation
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...