Difference between revisions of "CSC231 Final Exam 2014"

From dftwiki3
Jump to: navigation, search
Line 76: Line 76:
  
 
Please answer this question in the Moodle Final-Exam Problem 6 section.
 
Please answer this question in the Moodle Final-Exam Problem 6 section.
 +
<br />
 +
=Problem #7: Skype Art=
 +
<br />
 +
 +
<code><pre>
 +
(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)
 +
(d)(d)(d)(d)(d)(d)(d)(beer)(d)(beer)(d)(d)(^)(d)(d)(party)(party)(party)(d)(party)(party)(party)(d)(beer)(d)(beer)(d)(d)(d)(d)(d)(d)(d)
 +
(d)(d)(d)(d)(d)(d)(d)(beer)(d)(beer)(d)(^)(d)(^)(d)(party)(d)(party)(d)(party)(d)(party)(d)(beer)(d)(beer)(d)(d)(d)(d)(d)(d)(d)
 +
(d)(d)(d)(d)(d)(d)(d)(beer)(beer)(beer)(d)(^)(d)(^)(d)(party)(party)(party)(d)(party)(party)(party)(d)(d)(beer)(d)(d)(d)(d)(d)(d)(d)(d)
 +
(d)(d)(d)(d)(d)(d)(d)(beer)(d)(beer)(d)(^)(^)(^)(d)(party)(d)(d)(d)(party)(d)(d)(d)(d)(beer)(d)(d)(d)(d)(d)(d)(d)(d)
 +
(d)(d)(d)(d)(d)(d)(d)(beer)(d)(beer)(d)(^)(d)(^)(d)(party)(d)(d)(d)(party)(d)(d)(d)(d)(beer)(d)(d)(d)(d)(d)(d)(d)(d)
 +
(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)
 +
(d)(dance)(d)(d)(dance)(d)(party)(party)(party)(d)(*)(d)(*)(d)(*)(d)(d)(^)(d)(^)(d)(party)(party)(party)(d)(d)(h)(d)(d)(kiss)(kiss)(kiss)(d)
 +
(d)(dance)(dance)(d)(dance)(d)(party)(d)(d)(d)(*)(d)(*)(d)(*)(d)(d)(^)(d)(^)(d)(party)(d)(d)(d)(h)(d)(h)(d)(kiss)(d)(kiss)(d)
 +
(d)(dance) (dance) (dance)(d)(party)(party)(party)(d)(*)(d)(*)(d)(*)(d)(d)(d)(^)(d)(d)(party)(party)(party)(d)(h)(d)(h)(d)(kiss)(kiss)(kiss)(d)
 +
(d)(dance)(d)(dance)(dance)(d)(party)(d)(d)(d)(*)(d)(*)(d)(*)(d)(d)(d)(^)(d)(d)(party)(d)(d)(d)(h)(h)(h)(d)(kiss)(kiss)(d)(d)
 +
(d)(dance)(d)(d)(dance)(d)(party)(party)(party)(d)(d)(*)(d)(*)(d)(d)(d)(d)(^)(d)(d)(party)(party)(party)(d)(h)(d)(h)(d)(kiss)(d)(kiss)(d)
 +
(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)(d)
 +
</pre></code>
 +
 +
The characters above are shortcuts for Skype emoticons.  If you were to copy paste them into the Skype chat box, you would get this:
 +
 +
<br />
 +
<center>
 +
[[Image:SkypeArtHappyNewYear.gif|700px]]
 +
</center>
 +
 +
Note that the amount of memory required to store the message in ASCII (starting with '(d)') is significantly long.  We'd like to improve the storage requirement for such a string, and compress it.  For this purpose, we can use ''run-length encoding'' to compress the string. 
 +
 +
The ''run-length encoded'' version of the ''Happy New Year'' Skype Art written in assembly is given below:
 +
<br />
 +
<source lang="asm">
 +
art db 33, 3, 'd'
 +
db 1, 1, 10
 +
db 7, 3, 'd'
 +
db 1, 6, 'beer'
 +
db 1, 3, 'd'
 +
db 1, 6, 'beer'
 +
db 2, 3, 'd'
 +
db 1, 3, '^'
 +
db 2, 3, 'd'
 +
db 3, 7, 'party'
 +
db 1, 3, 'd'
 +
db 3, 7, 'party'
 +
db 1, 3, 'd'
 +
db 1, 6, 'beer'
 +
db 1, 3, 'd'
 +
db 1, 6, 'beer'
 +
db 7, 3, 'd'
 +
db 1, 1, 10
 +
db 7, 3, 'd'
 +
db 1, 6, 'beer'
 +
db 1, 3, 'd'
 +
db 1, 6, 'beer'
 +
db 1, 3, 'd'
 +
db 1, 3, '^'
 +
db 1, 3, 'd'
 +
db 1, 3, '^'
 +
db 1, 3, 'd'
 +
db 1, 7, 'party'
 +
db 1, 3, 'd'
 +
db 1, 7, 'party'
 +
db 1, 3, 'd'
 +
db 1, 7, 'party'
 +
db 1, 3, 'd'
 +
db 1, 7, 'party'
 +
db 1, 3, 'd'
 +
db 1, 6, 'beer'
 +
db 1, 3, 'd'
 +
db 1, 6, 'beer'
 +
db 7, 3, 'd'
 +
db 1, 1, 10
 +
db 7, 3, 'd'
 +
db 3, 6, 'beer'
 +
db 1, 3, 'd'
 +
db 1, 3, '^'
 +
db 1, 3, 'd'
 +
db 1, 3, '^'
 +
db 1, 3, 'd'
 +
db 3, 7, 'party'
 +
db 1, 3, 'd'
 +
db 3, 7, 'party'
 +
db 2, 3, 'd'
 +
db 1, 6, 'beer'
 +
db 8, 3, 'd'
 +
db 1, 1, 10
 +
db 7, 3, 'd'
 +
db 1, 6, 'beer'
 +
db 1, 3, 'd'
 +
db 1, 6, 'beer'
 +
db 1, 3, 'd'
 +
db 3, 3, '^'
 +
db 1, 3, 'd'
 +
db 1, 7, 'party'
 +
db 3, 3, 'd'
 +
db 1, 7, 'party'
 +
db 4, 3, 'd'
 +
db 1, 6, 'beer'
 +
db 8, 3, 'd'
 +
db 1, 1, 10
 +
db 7, 3, 'd'
 +
db 1, 6, 'beer'
 +
db 1, 3, 'd'
 +
db 1, 6, 'beer'
 +
db 1, 3, 'd'
 +
db 1, 3, '^'
 +
db 1, 3, 'd'
 +
db 1, 3, '^'
 +
db 1, 3, 'd'
 +
db 1, 7, 'party'
 +
db 3, 3, 'd'
 +
db 1, 7, 'party'
 +
db 4, 3, 'd'
 +
db 1, 6, 'beer'
 +
db 8, 3, 'd'
 +
db 1, 1, 10
 +
db 33, 3, 'd'
 +
db 1, 1, 10
 +
db 1, 3, 'd'
 +
db 1, 7, 'dance'
 +
db 2, 3, 'd'
 +
db 1, 7, 'dance'
 +
db 1, 3, 'd'
 +
db 3, 7, 'party'
 +
db 1, 3, 'd'
 +
db 1, 3, '*'
 +
db 1, 3, 'd'
 +
db 1, 3, '*'
 +
db 1, 3, 'd'
 +
db 1, 3, '*'
 +
db 2, 3, 'd'
 +
db 1, 3, '^'
 +
db 1, 3, 'd'
 +
db 1, 3, '^'
 +
db 1, 3, 'd'
 +
db 3, 7, 'party'
 +
db 2, 3, 'd'
 +
db 1, 3, 'h'
 +
db 2, 3, 'd'
 +
db 3, 6, 'kiss'
 +
db 1, 3, 'd'
 +
db 1, 1, 10
 +
db 1, 3, 'd'
 +
db 2, 7, 'dance'
 +
db 1, 3, 'd'
 +
db 1, 7, 'dance'
 +
db 1, 3, 'd'
 +
db 1, 7, 'party'
 +
db 3, 3, 'd'
 +
db 1, 3, '*'
 +
db 1, 3, 'd'
 +
db 1, 3, '*'
 +
db 1, 3, 'd'
 +
db 1, 3, '*'
 +
db 2, 3, 'd'
 +
db 1, 3, '^'
 +
db 1, 3, 'd'
 +
db 1, 3, '^'
 +
db 1, 3, 'd'
 +
db 1, 7, 'party'
 +
db 3, 3, 'd'
 +
db 1, 3, 'h'
 +
db 1, 3, 'd'
 +
db 1, 3, 'h'
 +
db 1, 3, 'd'
 +
db 1, 6, 'kiss'
 +
db 1, 3, 'd'
 +
db 1, 6, 'kiss'
 +
db 1, 3, 'd'
 +
db 1, 1, 10
 +
db 1, 3, 'd'
 +
db 3, 7, 'dance'
 +
db 1, 3, 'd'
 +
db 3, 7, 'party'
 +
db 1, 3, 'd'
 +
db 1, 3, '*'
 +
db 1, 3, 'd'
 +
db 1, 3, '*'
 +
db 1, 3, 'd'
 +
db 1, 3, '*'
 +
db 3, 3, 'd'
 +
db 1, 3, '^'
 +
db 2, 3, 'd'
 +
db 3, 7, 'party'
 +
db 1, 3, 'd'
 +
db 1, 3, 'h'
 +
db 1, 3, 'd'
 +
db 1, 3, 'h'
 +
db 1, 3, 'd'
 +
db 3, 6, 'kiss'
 +
db 1, 3, 'd'
 +
db 1, 1, 10
 +
db 1, 3, 'd'
 +
db 1, 7, 'dance'
 +
db 1, 3, 'd'
 +
db 2, 7, 'dance'
 +
db 1, 3, 'd'
 +
db 1, 7, 'party'
 +
db 3, 3, 'd'
 +
db 1, 3, '*'
 +
db 1, 3, 'd'
 +
db 1, 3, '*'
 +
db 1, 3, 'd'
 +
db 1, 3, '*'
 +
db 3, 3, 'd'
 +
db 1, 3, '^'
 +
db 2, 3, 'd'
 +
db 1, 7, 'party'
 +
db 3, 3, 'd'
 +
db 3, 3, 'h'
 +
db 1, 3, 'd'
 +
db 2, 6, 'kiss'
 +
db 2, 3, 'd'
 +
db 1, 1, 10
 +
db 1, 3, 'd'
 +
db 1, 7, 'dance'
 +
db 2, 3, 'd'
 +
db 1, 7, 'dance'
 +
db 1, 3, 'd'
 +
db 3, 7, 'party'
 +
db 2, 3, 'd'
 +
db 1, 3, '*'
 +
db 1, 3, 'd'
 +
db 1, 3, '*'
 +
db 4, 3, 'd'
 +
db 1, 3, '^'
 +
db 2, 3, 'd'
 +
db 3, 7, 'party'
 +
db 1, 3, 'd'
 +
db 1, 3, 'h'
 +
db 1, 3, 'd'
 +
db 1, 3, 'h'
 +
db 1, 3, 'd'
 +
db 1, 6, 'kiss'
 +
db 1, 3, 'd'
 +
db 1, 6, 'kiss'
 +
db 1, 3, 'd'
 +
db 1, 1, 10
 +
db 33, 3, 'd'
 +
db 1, 1, 10
 +
db 0
 +
</source>
 +
<br />
 +
Let's take the first few lines of this collection of bytes and decode it:
 +
<br />
 +
<source lang="asm">
 +
db 33, 3, 'd'
 +
db 1, 1, 10
 +
db 7, 3, 'd'
 +
db 1, 6, 'beer'
 +
</source>
 +
<br />
 +
The first line indicates that there are 33 emoticons of length 3, containing the letter 'd' inside.    In other words, 33 ''(d)'' emoticons.  Notice that we do not keep track of the parentheses since all emoticons have parentheses around them (except for one; stay tuned!).  Then we have 1 sequence of 1 character that is 10; that's a \n.  That one is the exception to the rule, and does not have parentheses around it.  Then we have 7 more '(d)', followed by one '(beer)' emoticon.  You should be able to understand the remainder of the series.  The series of emoticons is terminated by a 0-byte.
 +
 +
We assume that the number of emoticons on one line and the length of an emoticon will always be less than 256.
 +
<br />
 +
==Your assignment==
 +
<br />
 +
Write a program that contains the array ''Art'' in its data section, and that reconstructs the original multiline collection of emoticons that can be directly pasted into Skype.  Your program will print the reconstructed string.
 +
 +
<br />
 +
==Requirements==
 +
<br />
 +
* You may  use 231Lib.asm if you want.  Your output should be exactly the same as the text in the top box of this problem.
 +
* The Moodle test program will replace your '''Art''' array with a different, error free, string.  Do not write a program that simply outputs the expected result.  You will not be shown the actual string that will be fed to your program.
 +
<br />
 +
==Misc. ==
 +
<br />
 +
The run-length encoded version of the Skype art was created by a quickly hacked [[CSC231 Run-Length Encoding of Skype Art | Python program]].
 +
<br />
 +
==Submission==
 +
<br />
 +
Submit your program on Moodle. Call your program '''skypeArt.asm''', and submit it in the Final Exam, Problem 7 section.
 +
<br />
 
</onlydft>
 
</onlydft>
 
<br />
 
<br />

Revision as of 07:23, 11 December 2014

--D. Thiebaut (talk) 15:02, 9 December 2014 (EST)



...




...