15-112 Fall 2011 Contest
2
Due Never! (Optional activity)
Contest Date: Saturday, 10-Dec,
6pm to 8pm (ish)
Read these
instructions first!
- This is a team-based contest. Teams of 3 or 4 will be
assigned randomly at the start.
- While this is really just for fun (really!), to provide some incentive
and reward, each member of the winning team shall have the option of not
taking the final exam.
- More contest rules:
- You must work as a team. Any team not working as a team at any
point in the judgment of the contest officials shall be disqualified.
- You may not consult anyone except members of your own team, and when
you are physically separated from other teammates, you may talk to them
on cell phones, but you may not share code with them, either via
email or otherwise.
- In particular, please do not to call out answers as you get them,
nor as you submit them. That would spoil the fun for the other
teams.
- Part of this contest requires that you move through the halls of GHC
floors 3-5. Do so safely!
- You may not use an image editor for this contest. All image
editing must be done via your own Python programs.
- In fact, no guessing is allowed, and all your answers must be
generated by Python programs. After the contest, teams shall
submit a zip file of all their Python code, and contest officials will
confirm that the winning team used Python programs to solve all their
problems.
- You may use any code from the course website, but that is the only
code you may use.
- Except for copying code, which is disallowed, you may use web-based
resources at will.
- No using any previously-written code except from the course notes! (not
from your hw's, labs, web, etc)
- Style does not matter! go nuts!
- You may want to use this line (which is not in the notes, but save a
PhotoImage to the given file):
image.write("myFile.gif", format="gif")
- General contest structure
- The contest contains 3 sections.
- You must complete (or abandon) each section/phase before proceeding
to the next.
- Each section works as such:
- Phase 1: Crack the Image
- Get the encoded image
You start with an encoded image (which we supply). You are
also told how the image was encoded.
- Write the image decoder
You write a Python program that decodes the image. How
will you know if you've decoded it properly? Easy:
it will look like something coherent (otherwise, if you decode
improperly, it will not!). For this, you may wish to use
portions of
imagesDemo1.py and/or
imagesDemo4.py from
here. Again, you may want to use this line (which is
not in the notes, but save a PhotoImage to the given file):
image.write("myFile.gif",
format="gif")
- Produce the decoded image
The output of step 2 will be a decoded image. This image
is really a clue. It is a picture of something somewhere
in GHC floors 3-5.
- Find the edit/change/bug in the decoded image
Each decoded image has been altered ("Photoshopped") in some
way. You need to discover that change, which may well
require that you locate where the unaltered photo was taken.
Note that one encoding/decoding will turn out very grainy --
that is NOT the edit/change/bug you are looking for in that
photo!
- Submit the solution
Submit a sheet of paper with your team name, the problem
number (1, 2, or 3), and the edit/change/bug (in just a few
words). Remember not to say what is on your paper, so as
not to spoil the fun for others. When you submit,
the contest official will tell you if you are right or wrong.
If you are right, proceed to phase 2 of this section (see
below). But if you are wrong, continue with Phase 1 (or
abandon this section and move on to the next section's phase 1),
with a 10-minute penalty on each incorrect submission.
- Phase 2: Parallel Coding
This phase is designed to especially reward teamwork and
communication skills (hence its rather unusual design).
For this phase, note that there are 2 contest officials (CO1 and
CO2) in 2 separate locations (which will be explained at the start
of the contest). You will need to split your team up however
you choose so 1 or more of you is in one location and 1 or more is
at the other location. You may wish to use cell phones to
coordinate your actions, but again you may not share code with
teammates who are not physically with you.
- Get the problems
When you are ready for this phase, ask CO1 and separately
ask CO2 for the problem that goes with this stage. Note
that the problems CO1 and CO2 give you will be the same, and you
are not allowed to share code between the sub-teams working in
each location, though you may otherwise talk on the phone and
discuss the problems.
- Solve the problems
Working in parallel, solve the two problems.
- Submit the solutions simultaneously
Submit as above (a sheet of paper with your team name,
problem number, and the parallel coding solution).
However, you must submit the problems to CO1 and CO2 as close to
simultaneously as possible. You will be penalized for the
difference in time between the two submissions, where a
one-minute difference will effectively disqualify you from the
contest. Note that you can submit each problem only once,
right or wrong.
- Scoring
With the exception of computing the time-difference-penalty in
phase 2.3 above, all time will be measured in integral minutes from
the start of the contest.
Score = (time in minutes until contest official receives your
correct solution in each phase 1.5) +
10 * (# of
incorrect submissions to phase 1.5 above) +
(time in
minutes until contest official receives the first correct solution
in each phase 2.3) +
(sum of the #
of seconds between first and second submissions in each phase 2.3)
At the end of the contest, each unsolved problem's time will be
counted as the total time (so if the contest is 2 hours, unsolved
problems would count as 120 minutes). The contest officials
may extend the contest for up to 1 hour depending on
progress/interest of participants.
Section 1 / Phase 1:
Brighten Image
For this encoding, each component (red,
green, and blue) of each pixel's rgb value was divided by 32 (with an integer
result). So if the original rgb values of a pixel were (243, 0, 122), then
the encoded rgb values would be (7, 0, 3). Because of this, the resulting
encoded image is very dark, as you can see here:
image1-encoded.gif
To decode this image, you need to
brighten it by reversing the process
described above. Remember, you may not use an image editor; instead, you
must write a Python programmer that solves this!
Section 1 / Phase 2:
smallestConsecutiveHappysDifferingBy50
Note that the Phase 2 problems were
not available on the contest website during the actual contest, but are provided
here after the contest for recording purposes.
Find the smallest
consecutive pair of happy numbers that differ by 50, where happy numbers are
defined here:
http://en.wikipedia.org/wiki/Happy_number
(Note that you can tell if a number is happy if you get a 1, but it's unhappy if
you get a 4 eventually...) For example, the first two happy numbers are 1
and 7 and they differ by 6, so they are not the correct answer.
Section 2 / Phase 1:
Baboon Steganography
This time, the encoding uses
steganography, so the original image is
somehow embedded in another, unrelated image (baboons, as it happens), which we
will call the distractor image. Here is the encoded image:
image2-encoded.gif:
To decode this image, go to each pixel, get its rgb value, and take the bottom 3
bits of the red, green, and blue values. Assemble these into a single
9-bit integer (which you are guaranteed will be less than 256). That is
the grayscale value of the result, so set the red, green, and blue values of the
result all to this 9-bit integer value. For example, if the encoded image
has a pixel with RGB values (243, 0,
122), or, in base 2, (11110011, 00000000, 01111010),
then the bottom 3 bits from each are 011, 000, and 010, which concatenated
becomes 011000010, which equals 194. And so the corresponding pixel in the
decoded image has an RGB value of (194, 194, 194).
Section 2 / Phase 2:
leastCommonLetters
Find the least common letter(s) Aristotle used in ON SLEEP AND
SLEEPLESSNESS:
http://www.textfiles.com/etext/AUTHORS/ARISTOTLE/aristotle-on-267.txt
Count all the letters on the page, case-insensitively (so "a" and "A" are the
same), and ignore all non-letters).
Section 3 / Phase 1:
400 Tiles
This time, we take the original image (which happens to be 800x600) and
treat it as a 20x20 grid of cells. Then we swap cells repeatedly.
Which cells? For this, we need a pseudorandom number generator.
We will use this one: start with a "seed" (which we suggest you place in a
global variable) equal to 0. Each call to randint() will update the seed
so that it equals int((22695477*seed
+ 1) % (2**31)), so each value of the seed depends on the previous value.
Now, the randint() function does not actually return the seed itself, since the
lower bits of that value do not act very random. Instead, it returns
(seed>>16). If you implement
randint() properly, the first 4 values it returns will be 0, 346, 130, and 10982
in that order (confirm this!). Now, we need these to refer to rows and
cols, so we take each value %20, producing the values 0, 6, 10, and 2 in that
order. We treat these values as row1, col1, row2, and col2, respectively,
so our first step would be to swap cells (0, 6) and (10, 2). That is the
first swap. We will make one million swaps. Note that it is
possible that (row1,col1) is the same as (row2,col2) -- this still counts as a
swap. Here is the encoded image after one million swaps:
image3-encoded.gif:
To decode this, reverse the encoding process described above.
Section 3 / Phase 2:
pascalsOddMedian
If row 0 of Pascal's Triangle is [1], row 1 is [1,1], and row 2 is [1,2,1],
let's define pascalsOddMedian(row) to be the median of the odd numbers in the
given row.
What is pascalsOddMedian(20)+pascalsOddMedian(21)?
Good luck!!!
carpe diem - carpe
diem - carpe diem - carpe diem - carpe diem - carpe diem -
carpe diem - carpe diem - carpe diem