Improved ECC handout
This commit is contained in:
		| @ -4,7 +4,7 @@ An ISBN\footnote{International Standard Book Number} is a unique numeric book id | ||||
|  | ||||
| \vspace{3mm} | ||||
|  | ||||
| Say we have a sequence of nine digits, forming a partial ISBN-10: $n_1 n_2 ... n_9$. \\ | ||||
| Say we have a sequence of nine digits, forming a partial ISBN-10: $n_1 n_2 ... n_9$. \par | ||||
| The final digit, $n_{10}$, is calculated as follows: | ||||
|  | ||||
| $$ | ||||
| @ -41,8 +41,8 @@ $$ | ||||
|  | ||||
| 	\vspace{2mm} | ||||
|  | ||||
| 	$10n_1 + 9n_2 + ... + 2n_9 + n_{10} \equiv$ \\ | ||||
| 	$(-n_1) + (-2n_2) + ... + (-9n_9) + n_{10} =$ \\ | ||||
| 	$10n_1 + 9n_2 + ... + 2n_9 + n_{10} \equiv$ \par | ||||
| 	$(-n_1) + (-2n_2) + ... + (-9n_9) + n_{10} =$ \par | ||||
| 	$-n_{10} + n_{10} \equiv 0$ | ||||
|  | ||||
| 	\vspace{2mm} | ||||
| @ -54,7 +54,7 @@ $$ | ||||
| \vfill | ||||
|  | ||||
| \problem{} | ||||
| Take a valid ISBN-10 and change one digit. Is it possible that you get another valid ISBN-10? \\ | ||||
| Take a valid ISBN-10 and change one digit. Is it possible that you get another valid ISBN-10? \par | ||||
| Provide an example or a proof. | ||||
|  | ||||
| \begin{solution} | ||||
| @ -62,29 +62,29 @@ Provide an example or a proof. | ||||
|  | ||||
| 	\vspace{3mm} | ||||
|  | ||||
| 	If you change one digit of the ISBN, $S$ changes by $km$, where $k \in \{1,2,...,10\}$ and $|m| \leq 10$. \\ | ||||
| 	If you change one digit of the ISBN, $S$ changes by $km$, where $k \in \{1,2,...,10\}$ and $|m| \leq 10$. \par | ||||
| 	$k$ and $m$ cannot be divisible by 11, thus $km$ cannot be divisible by 11. | ||||
|  | ||||
| 	\vspace{3mm} | ||||
|  | ||||
| 	We know that $S \equiv 0 \text{ (mod 11)}$. \\ | ||||
| 	We know that $S \equiv 0 \text{ (mod 11)}$. \par | ||||
| 	After the change, the checksum is $S + km \equiv km \not\equiv 0 \text{ (mod 11)}$. | ||||
| \end{solution} | ||||
|  | ||||
| \vfill | ||||
|  | ||||
| \problem{} | ||||
| Take a valid ISBN-10 and swap two adjacent digits. When will the result be a valid ISBN-10? \\ | ||||
| Take a valid ISBN-10 and swap two adjacent digits. When will the result be a valid ISBN-10? \par | ||||
| This is called a \textit{transposition error}. | ||||
|  | ||||
|  | ||||
| \begin{solution} | ||||
| 	Let $n_1n_2...n_{10}$ be a valid ISBN-10. \\ | ||||
| 	Let $n_1n_2...n_{10}$ be a valid ISBN-10. \par | ||||
| 	When we swap $n_i$ and $n_{i+1}$, we subtract $n_i$ and add $n_{i+1}$ to the checksum. | ||||
|  | ||||
| 	\vspace{3mm} | ||||
|  | ||||
| 	If the new ISBN is to be valid, we must have that $n_{i+1} - n_i \equiv 0 \text{ (mod 11)}$. \\ | ||||
| 	If the new ISBN is to be valid, we must have that $n_{i+1} - n_i \equiv 0 \text{ (mod 11)}$. \par | ||||
| 	This is impossible unless $n_i = n_{i+1}$. Figure out why yourself. | ||||
| \end{solution} | ||||
|  | ||||
| @ -98,7 +98,7 @@ $$ | ||||
|  n_{13} = \Biggr[ \sum_{i=1}^{12} n_i \times (2 + (-1)^i) \Biggl] \text{ mod } 10 | ||||
| $$ | ||||
|  | ||||
| What is the last digit of the following ISBN-13? \\ | ||||
| What is the last digit of the following ISBN-13? \par | ||||
| \texttt{978-0-380-97726-?} | ||||
|  | ||||
| \begin{solution} | ||||
| @ -108,54 +108,54 @@ What is the last digit of the following ISBN-13? \\ | ||||
| \vfill | ||||
|  | ||||
| \problem{} | ||||
| Take a valid ISBN-13 and change one digit. Is it possible that you get another valid ISBN-13? \\ | ||||
| Provide an example or a proof. | ||||
| Take a valid ISBN-13 and change one digit. Is it possible that you get another valid ISBN-13? \par | ||||
| If you can, provide an example; if you can't, provide a proof. | ||||
|  | ||||
| \begin{solution} | ||||
| 	Let $n_1n_2...n_{13}$ be a valid ISBN-13. Choose some $n_i$ and change it to $m_i$. \\ | ||||
| 	Let $n_1n_2...n_{13}$ be a valid ISBN-13. Choose some $n_i$ and change it to $m_i$. \par | ||||
|  | ||||
| 	\vspace{3mm} | ||||
|  | ||||
| 	Since $n_i$, $m_i$ $\in \{0, 1, 2, ..., 9\}$, $-9 \leq n_i - m_i \leq 9$. \\ | ||||
| 	Since $n_i$, $m_i$ $\in \{0, 1, 2, ..., 9\}$, $-9 \leq n_i - m_i \leq 9$. \par | ||||
|  | ||||
| 	\vspace{2mm} | ||||
|  | ||||
| 	Case 0: $i$ is 13 \\ | ||||
| 	Case 0: $i$ is 13 \par | ||||
| 	This is trivial. | ||||
|  | ||||
| 	\vspace{2mm} | ||||
|  | ||||
| 	Case 1: $i$ is odd \\ | ||||
| 	For the new ISBN to be valid, we need $n_i - m_i \equiv 0 \text{ (mod 10)}$. \\ | ||||
| 	Case 1: $i$ is odd \par | ||||
| 	For the new ISBN to be valid, we need $n_i - m_i \equiv 0 \text{ (mod 10)}$. \par | ||||
| 	This cannot happen if $n_i \neq m_i$. | ||||
|  | ||||
| 	\vspace{2mm} | ||||
|  | ||||
| 	Case 2: $i$ is even \\ | ||||
| 	For the new ISBN to be valid, we need $3(n_i - m_i) \equiv 0 \text{ (mod 10)}$ \\ | ||||
| 	Case 2: $i$ is even \par | ||||
| 	For the new ISBN to be valid, we need $3(n_i - m_i) \equiv 0 \text{ (mod 10)}$ \par | ||||
| 	This cannot happen, 10 and 3 are coprime. | ||||
| \end{solution} | ||||
|  | ||||
| \vfill | ||||
|  | ||||
| \problem{} | ||||
| Take a valid ISBN-13 and swap two adjacent digits. When will the result be a valid ISBN-13? \\ | ||||
| Take a valid ISBN-13 and swap two adjacent digits. When will the result be a valid ISBN-13? \par | ||||
| \hint{The answer here is more interesting than it was last time.} | ||||
|  | ||||
| \begin{solution} | ||||
| 	Say we swap $n_i$ and $n_{i+1}$, where $i \in \{1, 2, ..., 11\}$. \\ | ||||
| 	The checksum changes by $2(n_{i+1} - n_i)$, and will \\ | ||||
| 	Say we swap $n_i$ and $n_{i+1}$, where $i \in \{1, 2, ..., 11\}$. \par | ||||
| 	The checksum changes by $2(n_{i+1} - n_i)$, and will \par | ||||
| 	remain the same if this value is $\equiv 0 \text{ (mod 10)}$. | ||||
| \end{solution} | ||||
|  | ||||
| \vfill | ||||
|  | ||||
| \problem{} | ||||
| \texttt{978-0-08-2066-46-6} was a valid ISBN until I changed a single digit. \\ | ||||
| Can you tell me which digit I changed? | ||||
| \problem{}<isbn-nocorrect> | ||||
| \texttt{978-0-08-2066-46-6} was a valid ISBN until I changed a single digit. \par | ||||
| Can you find the digit I changed? Can you recover the original ISBN? | ||||
|  | ||||
| \begin{solution} | ||||
| 	Nope, unless you look at the meaning of each digit in the spec. \\ | ||||
| 	Nope, unless you look at the meaning of each digit in the spec. \par | ||||
| 	If you're unlucky, maybe not even then. | ||||
| \end{solution} | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user