Skip to content

Commit

Permalink
tama editorial updates
Browse files Browse the repository at this point in the history
  • Loading branch information
kcvajgf committed Nov 1, 2023
1 parent dce3613 commit f77cf65
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 125 deletions.
2 changes: 1 addition & 1 deletion 2023/tama/griddy/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ <h3 id="a-straightforward-approach">A straightforward approach</h3>
<p>Anyway, the most straightforward solution would be to <em>just do it</em> as stated, a.k.a., <em>brute force</em>: enumerate all <span class="math inline">\(2^{rc}\)</span> grids, compute <span class="math inline">\(B(G)\)</span> for each of them, and then sum up all these <span class="math inline">\(B(G)^3\)</span>. Enumerating grids is relatively straightforward with backtracking, and for the first subtask, <span class="math inline">\(2^{rc} = 2^{25} = 33554432\)</span> which is quite manageable for a computer. The only missing ingredient to fully implement this solution is being able to compute <span class="math inline">\(B(G)\)</span> for a given grid <span class="math inline">\(G\)</span>.</p>
<h3 id="computing-bg">Computing <span class="math inline">\(B(G)\)</span></h3>
<p>We are given a grid with <span class="math inline">\(r\)</span> rows and <span class="math inline">\(c\)</span> columns, and we want to make it <em>based</em>, i.e., change it so that every row and every column has an even number of cringe memes.</p>
<p>Let’s convert a cool meme (🗿) into a <span class="math inline">\(0\)</span> and a cringe meme (😬) into a <span class="math inline">\(1\)</span>, so the condition translates to: the sum of every row and every column is even.</p>
<p>Let’s convert a cool meme (🗿) into a <span class="math inline">\(0\)</span> and a cringe meme (😬) into a <span class="math inline">\(1\)</span>, so the condition translates to: <strong>the sum of every row and every column is even.</strong></p>
<p>Now, the effect of flipping a cell is to flip the <span class="definition" data-bs-toggle="tooltip" data-bs-placement="bottom" title="The parity of a number is whether it’s odd or even. (The word “parity” itself is related to the word “pair”.)">parity</span> of exactly one row and exactly one column, namely the row and column containing the cell. Thus, if there are <span class="math inline">\(R\)</span> odd rows, then you need at least <span class="math inline">\(R\)</span> flips to make all these odd rows even. Similarly, if there are <span class="math inline">\(C\)</span> odd columns, then you need at least <span class="math inline">\(C\)</span> flips. Combining these tells us that we need <span class="math inline">\(\max(R, C)\)</span> or more moves to make the grid based.</p>
On the other hand, for every move, we can choose the row and column to flip <em>independently</em>. Thus, it seems intuitive that <span class="math inline">\(\max(R, C)\)</span> moves are enough. And indeed, it is:
<div class="theorem">
Expand Down
2 changes: 1 addition & 1 deletion 2023/tama/griddy/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Anyway, the most straightforward solution would be to *just do it* as stated, a.

We are given a grid with $r$ rows and $c$ columns, and we want to make it *based*, i.e., change it so that every row and every column has an even number of cringe memes.

Let&rsquo;s convert a cool meme (&#128511;) into a $0$ and a cringe meme (&#128556;) into a $1$, so the condition translates to: the sum of every row and every column is even.
Let&rsquo;s convert a cool meme (&#128511;) into a $0$ and a cringe meme (&#128556;) into a $1$, so the condition translates to: **the sum of every row and every column is even.**

Now, the effect of flipping a cell is to flip the <span class="definition" data-bs-toggle="tooltip" data-bs-placement="bottom" title="The parity of a number is whether it&rsquo;s odd or even. (The word &ldquo;parity&rdquo; itself is related to the word &ldquo;pair&rdquo;.)">parity</span> of exactly one row and exactly one column, namely the row and column containing the cell. Thus, if there are $R$ odd rows, then you need at least $R$ flips to make all these odd rows even. Similarly, if there are $C$ odd columns, then you need at least $C$ flips. Combining these tells us that we need $\max(R, C)$ or more moves to make the grid based.

Expand Down
2 changes: 1 addition & 1 deletion 2023/tama/lucas/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ <h3 id="generate-the-parities-separately">Generate the parities separately</h3>
<span class="cf">if</span> parity <span class="op">==</span> <span class="dv">0</span>:
total <span class="op">=</span> (total <span class="op">+</span> value<span class="op">**</span><span class="dv">2</span>) <span class="op">%</span> m</code></pre></div>
<div class="remarks">
<p><strong>Remark:</strong> You can also just compute the Lucas numbers modulo <span class="math inline">\(2m\)</span>; that way, reducing them modulo <span class="math inline">\(m\)</span> and <span class="math inline">\(2\)</span> is still valid. (Can you see why?)</p>
<p><strong>Remark:</strong> You could also just compute the Lucas numbers modulo <span class="math inline">\(2m\)</span>; that way, reducing them modulo <span class="math inline">\(m\)</span> and <span class="math inline">\(2\)</span> is still valid. (Can you see why?)</p>
</div>
<h3 id="pen-and-paper-insight">Pen-and-paper insight</h3>
It turns out that there’s a simple criterion that gives us the parity of a Lucas number given only its index.
Expand Down
2 changes: 1 addition & 1 deletion 2023/tama/lucas/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ for value, parity in zip(L, L_parity):
```

<div class="remarks">
**Remark:** You can also just compute the Lucas numbers modulo $2m$; that way, reducing them modulo $m$ and $2$ is still valid. (Can you see why?)
**Remark:** You could also just compute the Lucas numbers modulo $2m$; that way, reducing them modulo $m$ and $2$ is still valid. (Can you see why?)
</div>

### Pen-and-paper insight
Expand Down
Loading

0 comments on commit f77cf65

Please sign in to comment.