Cpsc121 2020w2 Hw4 Student
Cpsc121 2020w2 Hw4 Student
Cpsc121 2020w2 Hw4 Student
HW 4
Due: 19:00, Thursday April 13, 2021
Instructions:
1. Do not change the problem statements we are giving you. Simply add your
solutions by editing this latex document. To make it easier for the TAs to find
your solutions, please use the soln environment we provided as follows:
\begin{soln}
My solution is here.
\end{soln}
Your solution will then appear in blue, and be easier to differentiate from the
questions.
2. If you need more space, add a page between the existing pages using the
\newpage command.
3. Export the completed assignment as a PDF file for upload to gradescope.
4. On Gradescope, upload only one copy per partnership. You must identify
you group via Gradescope, not doing so may result in loosing some marks
5. You must also tell us, via Gradescope, where each of the problem parts
appears on your submission. You MUST align the regions for every problem,
even if your assignment solution isn’t complete. We will not be able to mark
any problem we can’t find. After uploading the .pdf you will a screen, where
you can click each question on the left, and click the corresponding page(s) for
which the question appears in. Because of this matching process, please allocate
at least 5 minutes prior to the deadline for submission. You must match your
answers with each question, not doing so may result in loosing some marks.
Academic Conduct: I certify that my assignment follows the academic
conduct rules for of CPSC 121 as outlined on the course website. As part of
those rules, when collaborating with anyone outside my group, (1) I and my
collaborators took no record but names away, and (2) after a suitable break,
my group created the assignment I am submitting without help from anyone
other than the course staff.
1
CPSC 121 Winter 2, 2020
1. [8 marks] Prove that for every three non-zero integers a, b and c, at least one of the
three products ab, ac, bc is positive. Hint: use a proof by contradiction.
2
CPSC 121 Winter 2, 2020
3
CPSC 121 Winter 2, 2020
3. [8 marks] The Fibonacci numbers are defined as follows: F0 = F1 = 1 and for every
i ≥ 2, Fi = Fi−1 + Fi−2 . We thus get the sequence
4
CPSC 121 Winter 2, 2020
From left to right, we will refer to these shapes as “O”, “L”, and “T” tetrominoes respec-
tively. Assume that each “square” of a tetromino occupies a single square unit area.
Prove, using strong induction, that any rectangular area with dimensions x × y, where
x and y are natural numbers each ≥ 2, and xy ≡ 0 mod 4 can be perfectly tiled using
only multiples of the three tetrominoes above. You are allowed to rotate the pieces, but
flipping (mirroring) is not necessary.
5
CPSC 121 Winter 2, 2020
5. [6 marks] Write a regular expression over the alphabet of {0..9, /} (i.e. numerals and
forward slash) that accepts strings representing positive rational numbers.
6
CPSC 121 Winter 2, 2020
• MYSTICWARRIORS
• MARSMATRIX
• SHOCKTROOPERS
• CONTRAHARDCORPS
• STRIDER
Clearly indicate the meaning of each state. Hint: there are three separate conditions
accepted strings must meet; states will need to encode whether or not they are met. You
can label an edge with the word “else” to indicate it would contain every character that
does not appear on another edge leaving from the same state. For instance, if a state has
outgoing edges labeled “E”, “R”, “S”, “T” and “else”, then “else” stands for “A, B, C, D, F,
G, H, I, J, K, L, M, N, O, Q, U, V, W, X, Y, Z”. Our solution uses 15 states in total,
with 3 “garbage” states to prevent crossing lines.