<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"><link href="https://oatzy.github.io/feed.xml" rel="self" type="application/atom+xml"/><link href="https://oatzy.github.io/" rel="alternate" type="text/html"/><updated>2026-11-16T00:01:04+00:00</updated><id>/feed.xml</id><title type="html">Questions Nobody Asked..</title><subtitle>Answering questions that nobody asked</subtitle><entry><title type="html">The AI That Came To Dinner</title><link href="https://oatzy.github.io/2026/11/09/ai-who-came-to-dinner.html" rel="alternate" type="text/html" title="The AI That Came To Dinner"/><published>2026-11-09T00:00:00+00:00</published><updated>2026-11-09T00:00:00+00:00</updated><id>/2026/11/09/ai-who-came-to-dinner</id><content type="html" xml:base="https://oatzy.github.io/2026/11/09/ai-who-came-to-dinner.html">&lt;p&gt;My job has indoctrinated me into the cult of AI.&lt;/p&gt;&#10;&lt;p&gt;All staff at our company are &amp;rsquo;expected&amp;rsquo; to embrace AI, and use it as much as possible. Truthfully, this doesn&amp;rsquo;t bother me - I&amp;rsquo;m lazy by nature, so if the computer wants to write code for me, I&amp;rsquo;m not going to fight it.&lt;/p&gt;&#10;&lt;p&gt;The effect is that I spend most of my work day in a Claude Code terminal, or else reviewing other people&amp;rsquo;s code (mostly written by Claude). But actually, prior to the adoption of AI, most of my work days were writing specs/tickets for juniors and reviewing the PRs they came back with. So not that different, really.&lt;/p&gt;&#10;&lt;p&gt;Anyway, after about 4 months, I&amp;rsquo;ve relented and spent my own money on a Claude subscription.&lt;/p&gt;&#10;&lt;p&gt;For what purpose?&lt;/p&gt;&#10;&lt;h1 id="a-cure-for-laziness"&gt;A Cure For Laziness&lt;/h1&gt;&#10;&lt;p&gt;I rarely write code outside of work.&lt;/p&gt;&#10;&lt;p&gt;And when I do, it&amp;rsquo;s rarely for coding&amp;rsquo;s own sake (&lt;a href="https://oatzy.github.io/2020/12/06/advent-of-code-2020-python-oneliners.html"&gt;Advent&lt;/a&gt; &lt;a href="https://oatzy.github.io/2021/12/02/advent-of-code-awk-oneliner.html"&gt;of&lt;/a&gt; &lt;a href="https://oatzy.github.io/2024/01/02/advent-of-code-jq.html"&gt;Code&lt;/a&gt; notwithstanding). Rather, I&amp;rsquo;ll have some idea, a &amp;lsquo;Question Nobody Asked&amp;rsquo; if you will, and code is just a means to an end.&lt;/p&gt;&#10;&lt;p&gt;When I thought about what I might do with a personal AI account, I thought back to past blogs - all the times I left something as &amp;lsquo;an exercise for the reader&amp;rsquo; because I was too lazy to finish it off myself. I thought about the &lt;a href="https://oatzy.github.io/2015/02/23/designing-general-relativity-based.html"&gt;gravity game&lt;/a&gt; that I designed but never built, in particular.&lt;/p&gt;&#10;&lt;p&gt;I also thought about the very last post here, and when I tried to have a local AI parse a recipe into json. And failed miserably.&lt;/p&gt;&#10;&lt;h1 id="fix-it"&gt;fix it&lt;/h1&gt;&#10;&lt;p&gt;Here&amp;rsquo;s how it went: I opened up Claude Code (Opus 5.5) in the &lt;code&gt;recipe_optimiser&lt;/code&gt; &lt;a href="https://github.com/oatzy/recipe-optimiser"&gt;repo&lt;/a&gt; and pointed it at the markdown version of that &lt;a href="https://oatzy.github.io/2026/01/04/cooking-for-software-engineers.html"&gt;last blog post&lt;/a&gt;, which explained the purpose of the repo.&lt;/p&gt;&#10;&lt;p&gt;Claude has a read and comes back with the following:&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code&gt;What would you like to do? Some ideas the post itself suggests:&#10;- Better scheduling: improve how clashing hands-on steps get resolved (&amp;#34;it could be better&amp;#34;).&#10;- Brute force: recipes don&amp;#39;t have many steps, so it could try every ordering and pick the best one.&#10;- Parser: try the JSON conversion with a bigger model.&#10;- Tidy-up: add a README, tests or a proper command-line interface.&#10;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;&amp;gt; create a claude skill to replace the parser&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;The first thing to do was replace the recipe parser. Originally it was intended to use a local model, but due to my low spec laptop it was entirely useless. So I got Claude to generate its own &lt;a href="https://github.com/oatzy/recipe-optimiser/blob/main/.claude/skills/parse-recipe/SKILL.md"&gt;&amp;lsquo;skill&amp;rsquo;&lt;/a&gt; (set of instructions), which works embarrassingly well with Opus 5.5&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code&gt;Steps I added (the recipe implies them but doesn&amp;#39;t list them):&#10;- 3a, bringing the water to the boil: 10 min&#10;&#10;Times I guessed:&#10;- 1, chop the onion: 5 min&#10;- 2, mince the garlic: 2 min&#10;- 3b, cook the spaghetti: 10 min (the recipe says &amp;#34;according to package instructions&amp;#34;)&#10;- 4a, heat the oil: 2 min&#10;- 6a, add the tomatoes and oregano and season: 1 min&#10;- 7, drain and combine: 1 min&#10;- 8, add the basil and serve: 1 min&#10;&#10;Times from the recipe: softening the onion (5), the garlic (1) and the simmer (10). I treated softening the onion as hands-on.&#10;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Then my professional developer brain kicked in, and said that I (Claude) should do the tidy-up it suggested (Tests! Docs! In this economy?)&lt;/p&gt;&#10;&lt;p&gt;Actually, that made a good basis for the next step - trying the brute-force idea I floated in the post. The unit tests encode the &amp;lsquo;rules&amp;rsquo; of the optimiser, so that the brute-force approach can be tested for correctness against the existing method.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;&amp;gt; let&amp;rsquo;s try the brute force approach and see how it compares&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;As it turns out, at least for the sample recipes I had, brute force is only marginally better than the heuristic-based algorithm I hand-rolled, and at the cost of the script taking longer to run.&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code&gt;┌───────────┬─────────────┬────────────┬──────────┬──────────────────┬──────────┐&#10;│ Recipe │ Approach │ Total time │ Waiting* │ Hands-on clashes │ Run time │&#10;├───────────┼─────────────┼────────────┼──────────┼──────────────────┼──────────┤&#10;│ Meatballs │ current │ 46 min │ 7 min │ 0 │ 6 ms │&#10;├───────────┼─────────────┼────────────┼──────────┼──────────────────┼──────────┤&#10;│ Meatballs │ brute force │ 46 min │ 6 min │ 0 │ 8.6 s │&#10;├───────────┼─────────────┼────────────┼──────────┼──────────────────┼──────────┤&#10;│ Spaghetti │ current │ 28 min │ 0 min │ 0 │ 1 ms │&#10;├───────────┼─────────────┼────────────┼──────────┼──────────────────┼──────────┤&#10;│ Spaghetti │ brute force │ 28 min │ 0 min │ 0 │ 1 ms │&#10;└───────────┴─────────────┴────────────┴──────────┴──────────────────┴──────────┘&#10;&#10;*Waiting is the minutes a not-prepable step (like hot oil) sits before the next step uses it. Some waiting can&amp;#39;t be avoided. For example, the oven finishes preheating before the meatballs go in, and both plans have that.&#10;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Not that I&amp;rsquo;m smug about it ;)&lt;/p&gt;&#10;&lt;p&gt;Then Claude had a suggestion of its own:&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;&amp;gt; try the OR-Tools solver and compare&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;This is an approach I wouldn&amp;rsquo;t have tried without AI, because I&amp;rsquo;m too lazy to learn how to use a &lt;a href="https://developers.google.com/optimization/introduction/python"&gt;SAT-solver&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;The key thing about a &lt;a href="https://en.wikipedia.org/wiki/SAT_solver"&gt;SAT-solver&lt;/a&gt; is it can find a &amp;lsquo;provably&amp;rsquo; most optimal solution (if one exists), and it does it a lot faster than brute-force.&lt;/p&gt;&#10;&lt;p&gt;As it turns out, when using the SAT-solver, the &lt;em&gt;total&lt;/em&gt; cooking time for the sample recipes still comes out at about the same as my heuristic method; but SAT is able to arrange steps so that there&amp;rsquo;s less waiting around.&lt;/p&gt;&#10;&lt;p&gt;In the repo, the SAT-solver replaced the brute-force code, but the brute-force is still viewable at this &lt;a href="https://github.com/oatzy/recipe-optimiser/commit/82217816e70236429a38070ae8c13b4895b69faa"&gt;commit&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;So far, my algorithm is performing a lot better than I expected. But maybe that&amp;rsquo;s a quirk of the sample recipes?&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;&amp;gt; search the web for some fair use recipes for a bigger test set&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;Most online recipes are copyrighted to the author, so Claude ended up pulling recipes from &lt;a href="https://en.wikibooks.org/wiki/Cookbook:Table_of_Contents"&gt;Wikibooks Cookbook&lt;/a&gt; (creative commons licensed).&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code&gt;What this shows:&#10;- Current method: it always matched the shortest total time of the waiting-first solver, but it left 1–4 minutes more waiting on three recipes (meatballs, fish and chips, shepherd&amp;#39;s pie).&#10;- Pad Thai shows the trade-off most clearly: the waiting-first plans take 44 minutes to avoid a single minute of waiting, where total and both finish in 39.&#10;- Fish and Chips has a lot of waiting that can&amp;#39;t be avoided. There&amp;#39;s only one fryer, so the chips are kept warm while the fish fries.&#10;- Speed: the solver takes under 0.2 s on all the new recipes. The meatballs are the slowest at 1.6 s with the waiting goal.&#10;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;And this is the problem with AI - it&amp;rsquo;s very easy to fall down a rabbit hole.&lt;/p&gt;&#10;&lt;p&gt;The &lt;a href="https://github.com/oatzy/recipe-optimiser"&gt;same repo&lt;/a&gt; has all of the updated code if you&amp;rsquo;re curious.&lt;/p&gt;&#10;&lt;h1 id="cooking-for-lazy-engineers"&gt;Cooking For Lazy Engineers&lt;/h1&gt;&#10;&lt;p&gt;I stopped doing the hand-optimisation shortly after writing the last post. And I never used the script in practice.&lt;/p&gt;&#10;&lt;p&gt;It just took too much time and effort. And I found that I started to care less about being so precise. Cooking, it turns out, is very forgiving. If something is ready too soon, you can turn the heat down low, or just pop a lid on it. It always works out in the end.&lt;/p&gt;&#10;&lt;p&gt;It started out a couple of times when I forgot to set my timer going and had to guess at when things were &amp;lsquo;ready&amp;rsquo;. Eventually, I didn&amp;rsquo;t bother with the timer at all. After a while, after enough practice, you learn to trust your eyes (and a thermometer) more than a clock.&lt;/p&gt;&#10;&lt;h1 id="a-why"&gt;A-Why?&lt;/h1&gt;&#10;&lt;p&gt;First and foremost, I want to reassure you that I will never let an AI anywhere near my (prose) writing. That much should be apparent from this post - despite the occasional emdash, I think my style is too erratic to ever be mistaken for AI.&lt;/p&gt;&#10;&lt;p&gt;In fact, one of the first things I put in my personal CLAUDE.md was &lt;em&gt;&amp;ldquo;I do not want [Claude] to write blog posts for me&amp;rdquo;&lt;/em&gt;. I&amp;rsquo;ve been writing this blog for &lt;a href="https://oatzy.github.io/2025/07/28/questions-nobody-asked.html"&gt;over 15 years&lt;/a&gt;, and the writing is &amp;rsquo;the point&amp;rsquo;.&lt;/p&gt;&#10;&lt;p&gt;But as alluded to, you may see more posts like this one, where I re-visit past posts to finish off the bits I was too lazy to do with my own ten fingers.&lt;/p&gt;&#10;&lt;p&gt;Future posts may also use AI to some degree. And as is my way, I will go into specific detail about &lt;em&gt;how&lt;/em&gt; I used it. I see too many posts and demos of people saying &amp;ldquo;look what I did with AI&amp;rdquo; without them really talking about how they did it. Personally, I think that&amp;rsquo;s the most interesting part.&lt;/p&gt;&#10;&lt;p&gt;I lied earlier. Yes, using Claude at work showed me what it was capable of. But I held out for the longest time because I didn&amp;rsquo;t want to pay out of pocket for something I didn&amp;rsquo;t have a &lt;em&gt;good&lt;/em&gt; use for. Revisiting old blogs is a fine idea, but it&amp;rsquo;s not worth the cost of a subscription.&lt;/p&gt;&#10;&lt;p&gt;What actually got me to pay up was a future project I have in mind - something involving crochet.&lt;/p&gt;&#10;&lt;p&gt;Watch this space&amp;hellip;&lt;/p&gt;&#10;&lt;p&gt;Chris.&lt;/p&gt;&#10;&lt;p&gt;[Maybe I could get Claude to fix the blog&amp;rsquo;s MathJax rendering.]&lt;/p&gt;&#10;</content><author><name>Chris Oates</name></author><category term="coding"/><category term="cooking"/><category term="hobby"/><category term="AI"/><summary type="html">&lt;p&gt;My job has indoctrinated me into the cult of AI.&lt;/p&gt;&#10;&lt;p&gt;All staff at our company are &amp;rsquo;expected&amp;rsquo; to embrace AI, and use it as much as possible. Truthfully, this doesn&amp;rsquo;t bother me - I&amp;rsquo;m lazy by nature, so if the computer wants to write code for me, I&amp;rsquo;m not going to fight it.&lt;/p&gt;&#10;&lt;p&gt;The effect is that I spend most of my work day in a Claude Code terminal, or else reviewing other people&amp;rsquo;s code (mostly written by Claude). But actually, prior to the adoption of AI, most of my work days were writing specs/tickets for juniors and reviewing the PRs they came back with. So not that different, really.&lt;/p&gt;</summary></entry><entry><title type="html">Cooking for Software Engineers</title><link href="https://oatzy.github.io/2026/01/04/cooking-for-software-engineers.html" rel="alternate" type="text/html" title="Cooking for Software Engineers"/><published>2026-01-04T19:00:00+00:00</published><updated>2026-01-04T19:00:00+00:00</updated><id>/2026/01/04/cooking-for-software-engineers</id><content type="html" xml:base="https://oatzy.github.io/2026/01/04/cooking-for-software-engineers.html">&lt;p&gt;The title is a reference to &amp;ldquo;Cooking for Engineers&amp;rdquo;, originally a &lt;a href="https://stevebennett.me/2010/11/26/introducing-cooking-for-engineers/"&gt;blog post&lt;/a&gt; which spun off into a &lt;a href="https://www.cookingforengineers.com/"&gt;whole site&lt;/a&gt;. It re-imagines recipes as flowchart-like diagrams.&lt;/p&gt;&#10;&lt;p&gt;The writer of the original blog post jokes that actual engineers would probably hate the approach due to how imprecise it is - using estimated measurements, and timings based on senses (what it looks like, smells like, etc).&lt;/p&gt;&#10;&lt;p&gt;Well allow me to share an alternative, precise and (over)engineered approach to recipes&lt;/p&gt;&#10;&lt;h1 id="the-secret-to-comedy"&gt;The Secret to Comedy*&lt;/h1&gt;&#10;&lt;p&gt;I&amp;rsquo;d say I&amp;rsquo;m a &amp;lsquo;capable&amp;rsquo; cook; I&amp;rsquo;m not skilled, but I can follow instructions.&lt;/p&gt;&#10;&lt;p&gt;Except, sometimes the instructions say things like &amp;ldquo;boil the rice&amp;hellip; meanwhile&amp;rdquo;, and I&amp;rsquo;m not sure if I&amp;rsquo;m supposed to start the &amp;lsquo;meanwhile&amp;rsquo; right away? Or, if I do that, will the sauce be ready too early? Or should I have already started?!&lt;/p&gt;&#10;&lt;p&gt;One solution to this is to plot everything out:&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;How long will each step take?&lt;/li&gt;&#10;&lt;li&gt;When does each step need to be completed (&amp;lsquo;ready&amp;rsquo;)?&lt;/li&gt;&#10;&lt;li&gt;Start at the end, and work backwards&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;Example:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;rice takes 20 mins&lt;/li&gt;&#10;&lt;li&gt;stir fry takes 15 mins&lt;/li&gt;&#10;&lt;li&gt;we want them ready at the same time&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;0 5 10 15 20&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;|---+---+---+---| rice&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; |---+---+---| stir fry&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;So, start the stir-fry 5 minutes after the rice. Easy.&lt;/p&gt;&#10;&lt;p&gt;This works for simple recipes with only a couple of things going on at once, where most of the things are &amp;lsquo;hands-off&amp;rsquo; (like boiling rice), and where everything is combined at the end.&lt;/p&gt;&#10;&lt;p&gt;When that isn&amp;rsquo;t the case, we need a more complicated process. It breaks down into two stages:&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;Dependency graph&lt;/li&gt;&#10;&lt;li&gt;Timeline&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;h1 id="hot-dags"&gt;Hot DAGs&lt;/h1&gt;&#10;&lt;p&gt;First, we have to break down the recipe into discrete steps, and arrange them into a dependency graph.&lt;/p&gt;&#10;&lt;p&gt;This means drawing a &amp;rsquo;node&amp;rsquo; for each step, with an arrow between the step and any steps that depend on it - you have to break an egg before you can fry your omelette.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[crack egg] -&amp;gt; [whisk egg] -&amp;gt; [fry]&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;What we end up with is something like a flowchart; in technical terms it&amp;rsquo;s a &amp;lsquo;&lt;a href="https://en.wikipedia.org/wiki/Directed_acyclic_graph"&gt;directed acyclic graph&lt;/a&gt;&amp;rsquo; (DAG)&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="/assets/cooking/dag.png" alt="Recipe DAG"&gt;&lt;/p&gt;&#10;&lt;p&gt;Here I&amp;rsquo;ve labelled nodes with step numbers; you can also use words. I didn&amp;rsquo;t draw arrows on the lines because I&amp;rsquo;m lazy (it&amp;rsquo;s read top-down).&lt;/p&gt;&#10;&lt;p&gt;The point of the graph is, it makes it easier to keep things in the right order when we come to do the timeline.&lt;/p&gt;&#10;&lt;p&gt;At this point, I also&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;assign approximate times to each step&lt;/li&gt;&#10;&lt;li&gt;identify whether the step is &amp;lsquo;hands on&amp;rsquo; (square) or &amp;lsquo;hands off&amp;rsquo; (round)&lt;/li&gt;&#10;&lt;li&gt;draw a squiggly line for steps that can be prepared in advance&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;It&amp;rsquo;s important to account for the time that &lt;em&gt;every&lt;/em&gt; step will take, whether that&amp;rsquo;s time roasting in the oven, time to chop an onion, or time to heat a drizzle of oil in a pan.&lt;/p&gt;&#10;&lt;p&gt;The mistake (one of the mistakes) I made in the past was not accounting for steps that aren&amp;rsquo;t explicitly timed; the recipe says to add the rice to boiling water and cook for 20 mins, but it doesn&amp;rsquo;t say how long it takes to bring a pan of water to the boil (it takes a while).&lt;/p&gt;&#10;&lt;p&gt;Some of the timing are likely to be different for different people. For example, it takes me a good 5 mins to thinly slice an onion (badly), while I imagine a skilled chef could do it in less than a minute.&lt;/p&gt;&#10;&lt;h1 id="sliding-timeline"&gt;Sliding Timeline&lt;/h1&gt;&#10;&lt;p&gt;This starts out the same as the original, basic approach&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;start at the last step(s) and work backwards&lt;/li&gt;&#10;&lt;li&gt;draw a block for each step&#10;&lt;ul&gt;&#10;&lt;li&gt;the block length represents how long the step takes&lt;/li&gt;&#10;&lt;li&gt;blocks have to be placed behind any steps they depend on (per the DAG)&lt;/li&gt;&#10;&lt;li&gt;indicate hands-off steps, e.g. with shading/colour&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;img src="/assets/cooking/timeline-initial.png" alt="Initial timeline"&gt;&lt;/p&gt;&#10;&lt;p&gt;This first pass is likely to be &amp;lsquo;wrong&amp;rsquo;. In the above, we have multiple (independent) hands-on steps happening at the same time, such as 5c and 6a.&lt;/p&gt;&#10;&lt;p&gt;This is where the sliding comes in, and where it helps to use a tablet (or pencil and eraser)&lt;/p&gt;&#10;&lt;p&gt;For steps that can be prepared ahead of time, we can slide them as far away from their dependants as we want; an onion can be chopped the night before if need be. Steps which can&amp;rsquo;t (reasonably) be prepared ahead of time need to slide together with their dependants, e.g. heating oil and frying an egg in that oil.&lt;/p&gt;&#10;&lt;p&gt;Honestly, the sliding is not an exact science. To some extend, you just have to feel it out; play around with it until you get something that works/feels right&lt;/p&gt;&#10;&lt;p&gt;Here&amp;rsquo;s what I settled on for the above example&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="/assets/cooking/timeline-optimised.png" alt="Optimised timeline"&gt;&lt;/p&gt;&#10;&lt;p&gt;Once you have your timeline, you can rewrite the recipe in this new ordering, or timestamp the steps, or just work off the timeline diagram&lt;/p&gt;&#10;&lt;p&gt;(Note, since we start at the last step and work backwards, the timeline is &lt;em&gt;read&lt;/em&gt; right-to-left.)&lt;/p&gt;&#10;&lt;h1 id="for-software-developers"&gt;For Software Developers&lt;/h1&gt;&#10;&lt;p&gt;The process I described is &amp;lsquo;fairly&amp;rsquo; mechanical, so it seems natural to try and code it up.&lt;/p&gt;&#10;&lt;p&gt;You can see my attempt here - &lt;a href="https://github.com/oatzy/recipe-optimiser/tree/pre-claude"&gt;https://github.com/oatzy/recipe-optimiser&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;em&gt;[edit]&lt;/em&gt; - I&amp;rsquo;ve since made some changes to the code using AI (see the follow-up post). The above link is to a tag of the repo as it existed when I wrote this post.&lt;/p&gt;&#10;&lt;p&gt;It&amp;hellip; kind of works. It could be better. (Remember when I said it&amp;rsquo;s not an exact science)&lt;/p&gt;&#10;&lt;p&gt;For the input, we have to re-structure the recipe into json, with steps defined like&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-json" data-lang="json"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;{&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;#34;id&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;2b&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;#34;duration&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;#34;hands_off&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;#34;parents&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="s2"&gt;&amp;#34;1a&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="s2"&gt;&amp;#34;2a&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;],&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;#34;instruction&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;Put meatballs in oven&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Here&amp;rsquo;s an example of what the script then generates&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[ 0 - 3] ### (1d) Grate the apple&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[ 3 - 6] ### (1f) Chop potatoes into chunks&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[ 6 - 8] ## (1c) Peel and grate the garlic&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[ 8 - 11] ### (1g) Combine ingredients for meatballs&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[11 - 16] ##### (2a) Roll mince into evenly-sized balls&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[11 - 16] XXXXX (1a) Pre-heat oven to 200&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[14 - 19] XXXXX (1b) Bring a large saucepan of water to the boil&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[16 - 31] XXXXXXXXXXXXXXX (2b) Put meatballs in oven&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[18 - 22] #### (1e) Slice the red onion&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[19 - 39] XXXXXXXXXXXXXXXXXXXX (2d) Boil the Potatoes&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[22 - 24] ## (3a) Heat oil in a large frying pan&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[24 - 34] XXXXXXXXXX (3b) Add onions to pan, fry until golden&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[31 - 32] # (2c) Remove from oven&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[32 - 34] ## (5c) Heat oil in medium sauce pan&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[34 - 36] ## (3c) Add balsamic vinegar and sugar, caramelise&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[36 - 37] # (4a) Add wine stock, etc. to onions&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[37 - 43] XXXXXX (4b) Bring to boil and simmer&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[37 - 39] ## (5d) Add cabbage and stir fry&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[39 - 40] # (5a) Drain potatoes&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[40 - 43] ### (5b) Mash potatoes&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[41 - 45] XXXX (5e) Cover, cook until tender&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[43 - 45] ## (6a) Stir meatballs into gravy&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[45 - 46] # (6b) Serve&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;(&lt;code&gt;X&lt;/code&gt; are hands-off, &lt;code&gt;#&lt;/code&gt; are hands-on)&lt;/p&gt;&#10;&lt;p&gt;Since recipes generally don&amp;rsquo;t have that many steps, an alternative approach might be to brute-force the &amp;lsquo;optimal&amp;rsquo; recipe.&lt;/p&gt;&#10;&lt;h2 id="ai-interlude"&gt;AI Interlude&lt;/h2&gt;&#10;&lt;p&gt;As mentioned, the script requires converting the recipe into a particular JSON format. This can be a tedious process.&lt;/p&gt;&#10;&lt;p&gt;Then, it occurred to me that parsing prose into json is something an LLM might be good at.&lt;/p&gt;&#10;&lt;p&gt;To try this out, I wanted to use a local model. Problem is, my laptop doesn&amp;rsquo;t have a lot of RAM, so the only model I can run locally is a really small one.&lt;/p&gt;&#10;&lt;p&gt;Turns out a really small LLM takes a long time to do a bad job of parsing.&lt;/p&gt;&#10;&lt;p&gt;So I asked Gemini to help me &lt;a href="https://github.com/oatzy/recipe-optimiser/blob/main/system_prompt.txt"&gt;improve the prompt&lt;/a&gt;, specifically for use with a small model - effectively asking an AI to dumb down the prompt for another, less intelligent AI.&lt;/p&gt;&#10;&lt;p&gt;It didn&amp;rsquo;t help.&lt;/p&gt;&#10;&lt;p&gt;And I don&amp;rsquo;t care enough to spend money on finding out if it works on a larger model, so&amp;hellip; moving on.&lt;/p&gt;&#10;&lt;h1 id="when-a-plan-comes-together"&gt;When a Plan Comes Together&lt;/h1&gt;&#10;&lt;p&gt;So having gone through all this planning, the whole cooking process runs smoothly now. Right?&lt;/p&gt;&#10;&lt;p&gt;The honest answer is: sometimes.&lt;/p&gt;&#10;&lt;p&gt;I actually used this approach when cooking Christmas dinner this year&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="/assets/cooking/christmas.jpg" alt="Christmas planning"&gt;&lt;/p&gt;&#10;&lt;p&gt;And I have to say, it was pleasing to set a timer going and be able to say &amp;ldquo;at minute 5 do X, at minute 10 do Y&amp;rdquo;. A lot less stressful too.&lt;/p&gt;&#10;&lt;p&gt;It&amp;rsquo;s also good for identifying what you need to prepare ahead of time, and what you have time to do while other stuff is cooking.&lt;/p&gt;&#10;&lt;p&gt;But the &amp;ldquo;Cooking for Engineers&amp;rdquo; guy was on to something - with cooking, you can rarely be so precise.&lt;/p&gt;&#10;&lt;p&gt;For example, when a recipe says to fry on &amp;ldquo;medium high&amp;rdquo; heat, that&amp;rsquo;s not an exact setting. Besides which, there are natural variations in people&amp;rsquo;s equipment, some ovens run hotter than others. Plus, the ingredients may vary in size or shape in a way that subtly affects cooking time.&lt;/p&gt;&#10;&lt;p&gt;So sometime you do just have to rely on your senses, make adjustments on the fly, and not get so hung up on following the plan.&lt;/p&gt;&#10;&lt;p&gt;Even if you spent more time working out the plan than it took to cook the damn meal&amp;hellip;&lt;/p&gt;&#10;&lt;p&gt;Chris&lt;/p&gt;&#10;&lt;p&gt;[the latest instalment in the &amp;ldquo;I started a new hobby and tried to solve it with maths&amp;rdquo; series]&lt;/p&gt;&#10;&lt;p&gt;*Timing&lt;/p&gt;&#10;</content><author><name>Chris Oates</name></author><category term="coding"/><category term="cooking"/><category term="hobby"/><summary type="html">&lt;p&gt;The title is a reference to &amp;ldquo;Cooking for Engineers&amp;rdquo;, originally a &lt;a href="https://stevebennett.me/2010/11/26/introducing-cooking-for-engineers/"&gt;blog post&lt;/a&gt; which spun off into a &lt;a href="https://www.cookingforengineers.com/"&gt;whole site&lt;/a&gt;. It re-imagines recipes as flowchart-like diagrams.&lt;/p&gt;&#10;&lt;p&gt;The writer of the original blog post jokes that actual engineers would probably hate the approach due to how imprecise it is - using estimated measurements, and timings based on senses (what it looks like, smells like, etc).&lt;/p&gt;&#10;&lt;p&gt;Well allow me to share an alternative, precise and (over)engineered approach to recipes&lt;/p&gt;</summary></entry><entry><title type="html">Pokemon TCG Pocket, Part 2 - How long it takes</title><link href="https://oatzy.github.io/2025/08/06/pokemon-part2-how-long.html" rel="alternate" type="text/html" title="Pokemon TCG Pocket, Part 2 - How long it takes"/><published>2025-08-06T19:00:00+00:00</published><updated>2025-08-06T19:00:00+00:00</updated><id>/2025/08/06/pokemon-part2-how-long</id><content type="html" xml:base="https://oatzy.github.io/2025/08/06/pokemon-part2-how-long.html">&lt;h1 id="champion"&gt;Champion&lt;/h1&gt;&#10;&lt;p&gt;In a &lt;a href="https://oatzy.github.io/2025/04/08/how-log-to-pull-pokemon.html"&gt;previous post&lt;/a&gt;, I used a simulation to predict how long it would take to complete the &lt;em&gt;Champion of the Sinnoh Region&lt;/em&gt; secret mission. It said that I should expect to open around 250 booster packs.&lt;/p&gt;&#10;&lt;p&gt;I have now completed that mission! And I finally have the Garchomp emblem I was after&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="/assets/pokemon-tcg-champion.jpg" alt="Garchomp emblem"&gt;&lt;/p&gt;&#10;&lt;p&gt;So how long did it &lt;em&gt;actually&lt;/em&gt; take?&lt;/p&gt;&#10;&lt;p&gt;On my &lt;strong&gt;253rd booster&lt;/strong&gt; (1265 pack points), I finally pulled the one-star &lt;em&gt;Gastrodon&lt;/em&gt; - the last one-star card I needed. I also had enough pack points to buy the missing two-star &lt;em&gt;Cynthia&lt;/em&gt; (1250 pp), completing the mission.&lt;/p&gt;&#10;&lt;p&gt;I wish I could say I felt more excited when that happened, but mostly I was just relieved that it was done with.&lt;/p&gt;&#10;&lt;h2 id="statistics"&gt;Statistics&lt;/h2&gt;&#10;&lt;p&gt;So, having opened 253 &lt;em&gt;Space-Time Smackdown&lt;/em&gt; booster packs - of which about 200 were the &lt;em&gt;Palkia&lt;/em&gt; variants - what did I end up with?&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;152/155&lt;/strong&gt; one- to four- diamond cards; 99/99 from &lt;em&gt;Palkia&lt;/em&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;20/24&lt;/strong&gt; one star cards; 12/12 from &lt;em&gt;Palkia&lt;/em&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;4/24&lt;/strong&gt; two-star cards (not counting &lt;em&gt;Cynthia&lt;/em&gt;); 3 from &lt;em&gt;Palkia&lt;/em&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;0&lt;/strong&gt; three-star (immersive) cards&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;1&lt;/strong&gt; crown (gold) card&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Counting duplicates, I pulled 43 one-star cards, 5 two-star cards, and 1,265 cards all together.&lt;/p&gt;&#10;&lt;p&gt;Oh, and I also pulled a rare booster. Which was quite a shock! But it didn’t have any of the cards I needed, which made me feel very ungrateful.&lt;/p&gt;&#10;&lt;h1 id="how-long-would-it-take-to-complete-the-set"&gt;How long would it take to complete the set?&lt;/h1&gt;&#10;&lt;p&gt;Given the above, a natural next question is how long would it take to complete the set?&lt;/p&gt;&#10;&lt;p&gt;I’m currently missing &lt;strong&gt;27&lt;/strong&gt; of the 207 cards from &lt;em&gt;Space-Time Smackdown&lt;/em&gt;.&lt;/p&gt;&#10;&lt;p&gt;That doesn’t sound like a lot, but they’re mostly two-star and higher.&lt;/p&gt;&#10;&lt;p&gt;The simulation I wrote for the previous post is not suited to answering this question. So I wrote a &lt;em&gt;brand new&lt;/em&gt; simulation - &lt;a href="https://github.com/oatzy/pokemon-tcg-pocket-sim"&gt;source code here&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;According to that simulation, I should expect to open about &lt;strong&gt;1400&lt;/strong&gt; more booster packs to complete the set, which is more than 5 times the number I’ve already opened!&lt;/p&gt;&#10;&lt;p&gt;I think you’ll all agree with me when I say: “nah&amp;hellip;”&lt;/p&gt;&#10;&lt;p&gt;For just the one- to four- diamond cards, I should expect to open about &lt;strong&gt;200&lt;/strong&gt; more packs.&lt;/p&gt;&#10;&lt;h1 id="sanity-check"&gt;Sanity check&lt;/h1&gt;&#10;&lt;p&gt;But wait a second, I’m only missing &lt;em&gt;3&lt;/em&gt; of the one- to four- diamond cards. Would it really take that many more packs?&lt;/p&gt;&#10;&lt;p&gt;This feels a little off. But how can we check?&lt;/p&gt;&#10;&lt;p&gt;An easy set to validate the simulation against in Mythic Island, since it doesn’t have any booster variants.&lt;/p&gt;&#10;&lt;p&gt;The new simulation gives us a breakdown of expected packs opened by rarity:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Crown&lt;/strong&gt;: &lt;em&gt;309.2062&lt;/em&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Three Star&lt;/strong&gt;: &lt;em&gt;89.547&lt;/em&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Two Star&lt;/strong&gt;: &lt;em&gt;656.0182&lt;/em&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;One Star&lt;/strong&gt;: &lt;em&gt;113.0376&lt;/em&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Four Diamond&lt;/strong&gt;: &lt;em&gt;136.5308&lt;/em&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Three Diamond&lt;/strong&gt;: &lt;em&gt;87.1258&lt;/em&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Two Diamond&lt;/strong&gt;: &lt;em&gt;57.6122&lt;/em&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;One Diamond&lt;/strong&gt;: &lt;em&gt;43.8046&lt;/em&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 id="immersive"&gt;Immersive&lt;/h2&gt;&#10;&lt;p&gt;Any easy rarity to validate is the three star ‘immersive’, since there’s only one of them.&lt;/p&gt;&#10;&lt;p&gt;In the &lt;a href="https://oatzy.github.io/2025/04/08/how-log-to-pull-pokemon.html"&gt;previous post&lt;/a&gt;, I showed how to calculate the probability of pulling a specific card from each booster. For the three star, this comes out to &lt;code&gt;1.12%&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;And since pulling the card is a &lt;a href="https://en.wikipedia.org/wiki/Bernoulli_trial"&gt;Bernoulli trial&lt;/a&gt;, the expected number of boosters is &lt;code&gt;1/p = 89&lt;/code&gt;, which is roughly equal to the simulated number.&lt;/p&gt;&#10;&lt;h2 id="diamond"&gt;Diamond&lt;/h2&gt;&#10;&lt;p&gt;There’s a 100% chance of pulling 3 one-diamond cards per booster. But for now, it’s easier pretend we pull one at a time.&lt;/p&gt;&#10;&lt;p&gt;If we pick one card from a set of 35 with equal probability, how long do we expect until we collect them all?&lt;/p&gt;&#10;&lt;p&gt;It seemed likely this was a well know problem with an exact solution, but I wasn’t sure how to identify it. This is the sort of thing AI is actually useful for&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;“Ah, a classic problem with a rather elegant solution! You&amp;rsquo;re asking about the &lt;strong&gt;Coupon Collector&amp;rsquo;s Problem”&lt;/strong&gt;&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&lt;p&gt;When it comes to AI, it&amp;rsquo;s best to check their work. Wikipedia confirms this is indeed &lt;a href="https://en.wikipedia.org/wiki/Coupon_collector's_problem"&gt;the problem I was looking for&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;The solution is &lt;code&gt;E[t] = n * Hn&lt;/code&gt; where &lt;code&gt;Hn&lt;/code&gt; is the &lt;a href="https://en.wikipedia.org/wiki/Harmonic_number"&gt;harmonic number&lt;/a&gt; &lt;code&gt;Hn = 1/1 + 1/2 + 1/3 + ... + 1/n&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;So, for the 35 common cards that comes to &lt;code&gt;145&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;And since we pull 3 per booster, that’s &lt;code&gt;48&lt;/code&gt; boosters.&lt;/p&gt;&#10;&lt;p&gt;Again. this agrees quite well with the simulation results.&lt;/p&gt;&#10;&lt;h2 id="star"&gt;Star&lt;/h2&gt;&#10;&lt;p&gt;The probability of pulling any one star is &lt;code&gt;12.595%&lt;/code&gt;, so we expect to pull one on average &lt;strong&gt;every 8 packs&lt;/strong&gt;.&lt;/p&gt;&#10;&lt;p&gt;The expected number of pulls to get all &lt;strong&gt;6&lt;/strong&gt; one-star cards is &lt;code&gt;14.7&lt;/code&gt;, so the expected number of packs is &lt;code&gt;8 * 14.7 = 117&lt;/code&gt;. Another close match.&lt;/p&gt;&#10;&lt;h2 id="and-so"&gt;And so&lt;/h2&gt;&#10;&lt;p&gt;You can follow similar logic for the other rarities.&lt;/p&gt;&#10;&lt;p&gt;At this point you might be wondering, did I waste my time writing a simulation, when there’s an exact solution?&lt;/p&gt;&#10;&lt;p&gt;Maybe.&lt;/p&gt;&#10;&lt;p&gt;To be fair, things get more complicated when you take into account variants and the ability to buy cards.&lt;/p&gt;&#10;&lt;p&gt;Anyway, the simulation results seem sound. I guess I was just lucky with my pulls. I did also get some of the cards from wonder picks, which probably throws off the numbers too.&lt;/p&gt;&#10;&lt;h1 id="free-to-play"&gt;Free to play&lt;/h1&gt;&#10;&lt;p&gt;Now we have the ability to simulate opening boosters, we can start to ask other questions.&lt;/p&gt;&#10;&lt;p&gt;For example, &lt;strong&gt;if I’m a free-to-play user&lt;/strong&gt; opening 2 booster packs a day for a month (until the new expansion is released), &lt;strong&gt;what cards do I expect to pull?&lt;/strong&gt; How many rare cards? How close do I get to completion?&lt;/p&gt;&#10;&lt;p&gt;Let’s take a more recent expansion: &lt;em&gt;Eevee Grove&lt;/em&gt;&lt;/p&gt;&#10;&lt;p&gt;If I open 2 * 30 = 60 boosters, I would expect&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;64&lt;/strong&gt; of the 69 diamond cards&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;10&lt;/strong&gt; one-star or rarer cards (not counting duplicates).&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;1/2&lt;/strong&gt; chance of pulling the three-star immersive card&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;1/8&lt;/strong&gt; chance of pulling the gold crown card&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;By comparison, if I go premium and open 3 packs a day, 90 per month, I would expect&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;67&lt;/strong&gt; out of 69 diamond cards&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;13&lt;/strong&gt; one-star or rarer cards&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;2/3&lt;/strong&gt; chance of pulling the immersive card&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;1/6&lt;/strong&gt; chance of pulling the crown&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;As for myself, I did manager to collect all the &lt;em&gt;Eevee Grove&lt;/em&gt; diamond cards after &lt;strong&gt;75 packs&lt;/strong&gt;, which is much less than the expected &lt;strong&gt;185 packs&lt;/strong&gt;.&lt;/p&gt;&#10;&lt;p&gt;But then, a couple of the rare and ex cards I got off wonder picks. Actually, after about 50 packs I was down to 3 cards missing, and just opening pack after pack with nothing new. I wouldn’t be surprised if it had taken another 100+ packs to get those last 3 if I hadn’t wonder picked them.&lt;/p&gt;&#10;&lt;h1 id="feature-creep"&gt;Feature creep&lt;/h1&gt;&#10;&lt;p&gt;With a solid base simulation, it’s very easy to keep adding features.&lt;/p&gt;&#10;&lt;p&gt;For one, I re-implemented the original mission simulation. Reassuringly, the results agree with the old one.&lt;/p&gt;&#10;&lt;p&gt;In fact, I wrote it so that you can define any mission you like in json format. You can also give it an ‘initial state’, what cards you’ve already pulled, to see how much longer it&amp;rsquo;ll take.&lt;/p&gt;&#10;&lt;p&gt;I may have gotten carried away.&lt;/p&gt;&#10;&lt;p&gt;I won’t go into the details here, you can have a look for yourself in &lt;a href="https://github.com/oatzy/pokemon-tcg-pocket-sim"&gt;the repo&lt;/a&gt;.&lt;/p&gt;&#10;&lt;h1 id="impossible-dream"&gt;Impossible dream&lt;/h1&gt;&#10;&lt;p&gt;I’ve been drafting this blog for a while. I was planning to post it in line with the release of the latest set &lt;em&gt;“Wisdom of Sea and Sky”&lt;/em&gt;, only to discover that the set introduces a new type of booster: &lt;em&gt;“regular plus one card”&lt;/em&gt;.&lt;/p&gt;&#10;&lt;p&gt;Naturally, I couldn’t post the blog until I’d updated the simulation to account for these new boosters. It turned out to be a little fiddly.&lt;/p&gt;&#10;&lt;p&gt;But now, finally, to wrap up - below are the number of packs you should expect to open to complete each of the expansions that have been released at time of writing:&lt;/p&gt;&#10;&lt;table&gt;&#10;&#9;&lt;thead&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;Expansion&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;Diamonds&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;Everything&lt;/th&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/thead&gt;&#10;&#9;&lt;tbody&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Genetic Apex&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;790&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;2052&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Mythical Island&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;149&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;659&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Space-Time Smackdown&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;460&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;1660&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Triumphant Light&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;190&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;832&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Shining Revelry&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;307&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;1137&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Celestial Guardians&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;485&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;2048&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Extradimensional Crisis&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;148&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;859&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Eevee Grove&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;182&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;906&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Wisdom of Sea and Sky&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;521&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;1820&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;p&gt;Considering the (current) release cadence of a new expansion every month, it is practically impossible to complete every set. It’d take a good while to complete just one set! (Unless you’re willing to spend A LOT of money).&lt;/p&gt;&#10;&lt;h1 id="conclusion"&gt;Conclusion&lt;/h1&gt;&#10;&lt;p&gt;In the previous post, I suggested that always opening the same booster would suck the joy out of the game. I definitely felt that, and wouldn’t recommend it.&lt;/p&gt;&#10;&lt;p&gt;But then, there’s a two-star full art &lt;em&gt;Garchomp&lt;/em&gt; in the &lt;em&gt;Triumphant Light&lt;/em&gt; expansion. Two two-star &lt;em&gt;Garchomps&lt;/em&gt; in fact!&lt;/p&gt;&#10;&lt;p&gt;And because I don’t learn my lessons, I’m at it again. Based on the simulation, I won’t have them any time soon&amp;hellip;&lt;/p&gt;&#10;&lt;p&gt;Chris.&lt;/p&gt;&#10;&lt;p&gt;[I wonder if I can simulate wonder picks]&lt;/p&gt;&#10;</content><author><name>Chris Oates</name></author><category term="maths"/><category term="probability"/><category term="pokemon"/><category term="pokemon tcg pocket"/><summary type="html">&lt;h1 id="champion"&gt;Champion&lt;/h1&gt;&#10;&lt;p&gt;In a &lt;a href="https://oatzy.github.io/2025/04/08/how-log-to-pull-pokemon.html"&gt;previous post&lt;/a&gt;, I used a simulation to predict how long it would take to complete the &lt;em&gt;Champion of the Sinnoh Region&lt;/em&gt; secret mission. It said that I should expect to open around 250 booster packs.&lt;/p&gt;&#10;&lt;p&gt;I have now completed that mission! And I finally have the Garchomp emblem I was after&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="/assets/pokemon-tcg-champion.jpg" alt="Garchomp emblem"&gt;&lt;/p&gt;&#10;&lt;p&gt;So how long did it &lt;em&gt;actually&lt;/em&gt; take?&lt;/p&gt;&#10;&lt;p&gt;On my &lt;strong&gt;253rd booster&lt;/strong&gt; (1265 pack points), I finally pulled the one-star &lt;em&gt;Gastrodon&lt;/em&gt; - the last one-star card I needed. I also had enough pack points to buy the missing two-star &lt;em&gt;Cynthia&lt;/em&gt; (1250 pp), completing the mission.&lt;/p&gt;</summary></entry><entry><title type="html">Questions Nobody Asked</title><link href="https://oatzy.github.io/2025/07/28/questions-nobody-asked.html" rel="alternate" type="text/html" title="Questions Nobody Asked"/><published>2025-07-28T18:00:00+00:00</published><updated>2025-07-28T18:00:00+00:00</updated><id>/2025/07/28/questions-nobody-asked</id><content type="html" xml:base="https://oatzy.github.io/2025/07/28/questions-nobody-asked.html">&lt;p&gt;15 years ago, I was unemployed. I&amp;rsquo;d dropped out of university the year before and my job prospects weren&amp;rsquo;t looking good.&lt;/p&gt;&#10;&lt;p&gt;I was spending a lot of time on Twitter (presently X). And I noticed some patterns, the ways different users behaved. And I wrote &lt;a href="https://oatzy.github.io/2010/07/28/how-do-you-categorise-tweets-obviously.html"&gt;a blog post about it&lt;/a&gt;.&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;Some years earlier, when I was in secondary school, I created my first blog on MSN Spaces. It was called &amp;ldquo;Philosophical Sheep&amp;rdquo;, after a doodle I would draw on my exam revision notes&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="/assets/philosophical-sheep.jpg" alt="philosophical sheep"&gt;&lt;/p&gt;&#10;&lt;p&gt;(&lt;em&gt;this is a recreation&lt;/em&gt;)&lt;/p&gt;&#10;&lt;p&gt;I read a lot of ‘popular maths&amp;rsquo; books at the time: &lt;a href="https://www.goodreads.com/book/show/131305.Fermat_s_Last_Theorem"&gt;Fermat&amp;rsquo;s Last Theorem&lt;/a&gt;, &lt;a href="https://www.goodreads.com/book/show/208916.The_Music_of_the_Primes"&gt;Music of the Primes&lt;/a&gt;; going back to the books that first sparked my interest in maths: &lt;a href="https://www.goodreads.com/book/show/1225641.Why_Do_Buses_Come_in_Threes_The_Hidden_Mathematics_of_Everyday_Life"&gt;Why Do Buses Come in Threes&lt;/a&gt; and its sequel &lt;a href="https://www.goodreads.com/book/show/632979.How_Long_Is_a_Piece_of_String_"&gt;How Long is a Piece of String&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;I thought that I&amp;rsquo;d like to do something like that - explain maths-y things in a way that was interesting and accessible to casual readers.&lt;/p&gt;&#10;&lt;p&gt;The first blog post was called &amp;ldquo;How to Weigh the Sun&amp;rdquo;, making use of Newton&amp;rsquo;s law of gravitation, angular momentum, and algebra.&lt;/p&gt;&#10;&lt;p&gt;The only person who read it (to my knowledge) was my sister. Her comment was along the lines of &amp;ldquo;you&amp;rsquo;re such a geek&amp;rdquo;. Which is hard to argue.&lt;/p&gt;&#10;&lt;p&gt;The second, and last, post on that blog was about houses of cards: how many cards do you need to build a house of a given height, and how high of a house you can build with a standard deck (5 rows).&lt;/p&gt;&#10;&lt;p&gt;The post ended&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;And basically, that&amp;rsquo;s it. Answers to questions you&amp;rsquo;d probably never ask.&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&lt;p&gt;That was where this blog got its name: &lt;em&gt;Questions Nobody Asked&lt;/em&gt;&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;I ultimately went back to university (a different one), and completed my degree. But before that, I wrote a lot more blog posts.&lt;/p&gt;&#10;&lt;p&gt;At that time, I thought that the blog might even help me get a job (or at least that&amp;rsquo;s what I told my parents).&lt;/p&gt;&#10;&lt;p&gt;The name of this blog is kind of ironic - each post does start with a question that &lt;em&gt;I&lt;/em&gt; asked. Something I&amp;rsquo;m curious about. Or sometimes the question is just &amp;ldquo;I wonder if I can&amp;rdquo;&lt;/p&gt;&#10;&lt;p&gt;And I try to answer those questions using the tools I have at my disposal: maths, physics, coding.&lt;/p&gt;&#10;&lt;p&gt;If I find an answer, and especially if the answer or the process of finding it is interesting, then I write about it. Because I want to share this cool thing I did.&lt;/p&gt;&#10;&lt;p&gt;And I want to explain it in a way that casual readers can understand, and hopefully find interesting.&lt;/p&gt;&#10;&lt;p&gt;That&amp;rsquo;s the reason I keep writing this blog.&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;When I applied for my current job, I included a link to this blog. On my first day, when I met my line manager, he said that what he found appealing, more than the topics of the posts (which aren&amp;rsquo;t really applicable to the job), was that it showed how I think through problems.&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;ve been working there almost 10 years now.&lt;/p&gt;&#10;&lt;p&gt;Granted, I haven&amp;rsquo;t written as many posts since then. But then, it&amp;rsquo;s a lot easier to find the time when you&amp;rsquo;re unemployed ;)&lt;/p&gt;&#10;&lt;p&gt;I started this blog 15 years and 136 posts ago.&lt;/p&gt;&#10;&lt;p&gt;I thought I should mark the occasion&lt;/p&gt;&#10;&lt;p&gt;Chris.&lt;/p&gt;&#10;&lt;p&gt;[I don&amp;rsquo;t think my sister reads the blog anymore]&lt;/p&gt;&#10;</content><author><name>Chris Oates</name></author><category term="biographical"/><summary type="html">&lt;p&gt;15 years ago, I was unemployed. I&amp;rsquo;d dropped out of university the year before and my job prospects weren&amp;rsquo;t looking good.&lt;/p&gt;&#10;&lt;p&gt;I was spending a lot of time on Twitter (presently X). And I noticed some patterns, the ways different users behaved. And I wrote &lt;a href="https://oatzy.github.io/2010/07/28/how-do-you-categorise-tweets-obviously.html"&gt;a blog post about it&lt;/a&gt;.&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;Some years earlier, when I was in secondary school, I created my first blog on MSN Spaces. It was called &amp;ldquo;Philosophical Sheep&amp;rdquo;, after a doodle I would draw on my exam revision notes&lt;/p&gt;</summary></entry><entry><title type="html">When will I get the cards I want in Pokemon TCG Pocket</title><link href="https://oatzy.github.io/2025/04/08/how-log-to-pull-pokemon.html" rel="alternate" type="text/html" title="When will I get the cards I want in Pokemon TCG Pocket"/><published>2025-04-08T19:40:00+00:00</published><updated>2025-04-08T19:40:00+00:00</updated><id>/2025/04/08/how-log-to-pull-pokemon</id><content type="html" xml:base="https://oatzy.github.io/2025/04/08/how-log-to-pull-pokemon.html">&lt;p&gt;When Pokemon first took the world by storm, I was 8 years old. Which is to say, I was the perfect age for it. And I was WAY into it.&lt;/p&gt;&#10;&lt;p&gt;Nearly 30 years later, and &lt;a href="https://oatzy.github.io/2022/05/28/data-structure-pokemon-cards.html"&gt;something&lt;/a&gt; of it is still deeply ingrained in my psyche. So when Pokemon TCG Pocket was released, I was an easy mark.&lt;/p&gt;&#10;&lt;h1 id="secret-mission"&gt;Secret Mission&lt;/h1&gt;&#10;&lt;p&gt;Garchomp is my favourite Pokemon, so when the second expansion — Space Time Smackdown — was release with a full-art Garchomp, I had to have it.&lt;/p&gt;&#10;&lt;p&gt;And I got it!&lt;/p&gt;&#10;&lt;p&gt;But then I learned about secret mission: &lt;a href="https://www.eurogamer.net/pokemon-tcg-pocket-secret-missions#section-12"&gt;Champion of the Sinnoh Region&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Completing this mission would earn me a Garchomp emblem, to proudly display on my player profile.&lt;/p&gt;&#10;&lt;p&gt;How hard could it be?&lt;/p&gt;&#10;&lt;p&gt;To complete the secret mission, I would need to collect:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Garchomp (one star)&lt;/li&gt;&#10;&lt;li&gt;Lucario (one star)&lt;/li&gt;&#10;&lt;li&gt;Gastrodon (one star)&lt;/li&gt;&#10;&lt;li&gt;Spiritomb (one star)&lt;/li&gt;&#10;&lt;li&gt;Cynthia (two star)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Luckily, by that point I already had the Garchomp and Lucario, so I only needed 2 more one star cards and a two star card to complete the mission.&lt;/p&gt;&#10;&lt;h1 id="getting-cards"&gt;Getting cards&lt;/h1&gt;&#10;&lt;p&gt;There are four ways to acquire a given card&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;pull it from a booster pack&lt;/li&gt;&#10;&lt;li&gt;wonder pick it&lt;/li&gt;&#10;&lt;li&gt;trade for it&lt;/li&gt;&#10;&lt;li&gt;buy it with pack points&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;We’ll come back to (1)&lt;/p&gt;&#10;&lt;h2 id="wonder-pick"&gt;Wonder Pick&lt;/h2&gt;&#10;&lt;p&gt;Wonder pick shows you sets of cards that other players pulled when opening a booster pack. You can chose a set, and the cards from that set are placed face-down and shuffled. You then pick one, and get a copy of whatever is revealed.&lt;/p&gt;&#10;&lt;p&gt;There are 5 cards to pick from, which means a 1 in 5 chance of getting the card you want, which is much better odds than pulling the card from a booster pack.&lt;/p&gt;&#10;&lt;p&gt;However, this only works if the card you want is available to pick at all. This becomes less and less likely over time, as new expansions are released and players open fewer boosters from the older expansions.&lt;/p&gt;&#10;&lt;p&gt;For that reason, this method is too unreliable to take into account.&lt;/p&gt;&#10;&lt;h2 id="trade"&gt;Trade&lt;/h2&gt;&#10;&lt;p&gt;The trade feature is trash, and we won’t dignify it with further discussion.&lt;/p&gt;&#10;&lt;p&gt;&lt;em&gt;[edit]&lt;/em&gt;: In August 2025, the trade feature was significantly improved with the introduction of wishlists.&#10;This potentially helps with obtaining the one star cards, tho it&amp;rsquo;s still not possible to trade two star cards.&lt;/p&gt;&#10;&lt;h2 id="pack-points"&gt;Pack Points&lt;/h2&gt;&#10;&lt;p&gt;With each booster pack you open, you earn 5 pack points (pp), and with enough pack points you can out-right buy the card you want.&lt;/p&gt;&#10;&lt;p&gt;The number of points required to buy a card depends on its rarity. In my case, the relevance numbers are&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;one star: 400 pp&lt;/li&gt;&#10;&lt;li&gt;two star: 1250 pp&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;So all together, I would need&amp;hellip; 2050 pp.&lt;/p&gt;&#10;&lt;p&gt;To achieve that many pack points, I would need to open &lt;strong&gt;410 booster packs&lt;/strong&gt;. Let’s put that in context.&lt;/p&gt;&#10;&lt;p&gt;If you’re a free-to-play player, you get to open 2 booster packs a day. That means it would take 205 days to get the required number of points, or &lt;strong&gt;almost 7 months&lt;/strong&gt;!&lt;/p&gt;&#10;&lt;p&gt;If, instead, you pay for a premium pass (£7.99/month), you get to open a third pack per day, bringing it down to 137 days or about 4.5 months.&lt;/p&gt;&#10;&lt;p&gt;It’s not impossible, but it would suck the joy out of the game; always opening packs from the same expansion, and in most cases getting low value duplicates over and over.&lt;/p&gt;&#10;&lt;p&gt;There are various missions and bonuses which allow you to open more booster packs per month, but not enough to move the needle much.&lt;/p&gt;&#10;&lt;h3 id="cold-hard-cash"&gt;Cold hard cash&lt;/h3&gt;&#10;&lt;p&gt;What if you wanted to buy the booster packs with real money?&lt;/p&gt;&#10;&lt;p&gt;The best deal just now is to buy the 690 Pokemon gold bundle (500 paid + 190 ‘free’) for £79.99.&lt;/p&gt;&#10;&lt;p&gt;One booster pack costs 6 gold, so the bundle would give you 115 booster packs at a cost of about 69.5p per pack.&lt;/p&gt;&#10;&lt;p&gt;So, to open the 410 booster packs, I would have to pay &lt;strong&gt;£285&lt;/strong&gt; !&lt;/p&gt;&#10;&lt;p&gt;Yeah. That’s a lot of money to spend on an imaginary object.&lt;/p&gt;&#10;&lt;h2 id="booster-packs"&gt;Booster Packs&lt;/h2&gt;&#10;&lt;p&gt;But wait, let’s go back to point (1).&lt;/p&gt;&#10;&lt;p&gt;Sure, pack points are a guaranteed way to get the cards you want, but if you’re opening 410 booster packs, that’s ample opportunity to just pull some of those cards. Right?&lt;/p&gt;&#10;&lt;h1 id="offering-rates"&gt;Offering Rates&lt;/h1&gt;&#10;&lt;p&gt;Helpfully, the game shares it’s “offering rates” — the probability of pulling each card.&lt;/p&gt;&#10;&lt;p&gt;So, what’s the probability of getting one or more of the desired cards when opening 410 booster packs?&lt;/p&gt;&#10;&lt;p&gt;The relevant offering rates break down like so:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;each booster pack contains 5 cards&lt;/li&gt;&#10;&lt;li&gt;in regular booster packs&#10;&lt;ul&gt;&#10;&lt;li&gt;the first 3 cards are always one diamond ‘common’ cards, so we can ignore them&lt;/li&gt;&#10;&lt;li&gt;for the 4th card&#10;&lt;ul&gt;&#10;&lt;li&gt;one star - &lt;em&gt;0.214%&lt;/em&gt;&lt;/li&gt;&#10;&lt;li&gt;two star - &lt;em&gt;0.041%&lt;/em&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;for the 5th card&#10;&lt;ul&gt;&#10;&lt;li&gt;one star - &lt;em&gt;0.857%&lt;/em&gt;&lt;/li&gt;&#10;&lt;li&gt;two star - &lt;em&gt;0.166%&lt;/em&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;the probability of opening a ‘rare’ booster - &lt;em&gt;0.05%&lt;/em&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;in a rare booster there are 5 rare cards&lt;/li&gt;&#10;&lt;li&gt;all rare cards (including one and two star) have the same probability - &lt;em&gt;3.846%&lt;/em&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Note, these offering rates apply to the Space Time Smackdown booster packs. Other expansions may have different rates.&lt;/p&gt;&#10;&lt;h2 id="pull-probabilities"&gt;Pull probabilities&lt;/h2&gt;&#10;&lt;p&gt;Let’s start by looking at the probability of pulling a one star card from a regular booster&lt;/p&gt;&#10;&lt;p&gt;It’s easiest to calculate the &lt;a href="https://oatzy.github.io/2011/08/08/quick-look-dont-blink.html"&gt;probability of NOT&lt;/a&gt; pulling the card (not card 4 and not card 5), then subtract from 1&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-cpp" data-lang="cpp"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;one&lt;/span&gt; &lt;span class="n"&gt;star&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;one&lt;/span&gt; &lt;span class="n"&gt;star&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;one&lt;/span&gt; &lt;span class="n"&gt;star&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mf"&gt;0.00214&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mf"&gt;0.00857&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.0107&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Calculated the same way, the two star probability is &lt;code&gt;p(two star) = 0.00207&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;For rare booster packs, there are 5 opportunities for pulling a given card, with the same probability each time, and a card may appear more than once&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-cpp" data-lang="cpp"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rare&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mf"&gt;0.0384&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;^&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.178&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The probability is the same for both one and two star cards.&lt;/p&gt;&#10;&lt;p&gt;Combining the probabilities for rare and regular boosters, we get&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-cpp" data-lang="cpp"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;P&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;one&lt;/span&gt; &lt;span class="n"&gt;star&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.0108&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;P&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;two&lt;/span&gt; &lt;span class="n"&gt;star&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.00216&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="opening-boosters"&gt;Opening boosters&lt;/h2&gt;&#10;&lt;p&gt;We want to know the probability of pulling one or more copies of a card while opening a large number of booster packs&lt;/p&gt;&#10;&lt;p&gt;As before, it’s easiest to come at it via the probability of not pulling the card in any booster&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-cpp" data-lang="cpp"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;card&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;card&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="o"&gt;^&lt;/span&gt; &lt;span class="n"&gt;N&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;As previously mentioned, I would have to open N = 410 booster packs to get the required number of pack points, so we have&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-cpp" data-lang="cpp"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;one&lt;/span&gt; &lt;span class="n"&gt;star&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;410&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.988&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;two&lt;/span&gt; &lt;span class="n"&gt;star&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;410&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.588&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In other words, I’m almost certainly going to pull one or both of the one star cards, but the two star card is only slightly better 50:50&lt;/p&gt;&#10;&lt;p&gt;The probability of pulling all three is &lt;em&gt;58.7%&lt;/em&gt;&lt;/p&gt;&#10;&lt;p&gt;But, if I do pull a one star card, I won’t need to buy it with pack points, so then don’t need to open as many boosters. But opening fewer boosters decreases the probability of pulling the card. Is there some sweet spot?&lt;/p&gt;&#10;&lt;h1 id="simulation"&gt;Simulation&lt;/h1&gt;&#10;&lt;p&gt;How many boosters should I expect to open before I either pull all the cards, or else have enough points to buy the cards I haven’t pulled yet?&lt;/p&gt;&#10;&lt;p&gt;This is more difficult to calculate from pure probability, so I used a &lt;a href="https://en.wikipedia.org/wiki/Monte_Carlo_method"&gt;simulation&lt;/a&gt; instead — &lt;a href="https://github.com/oatzy/pokemon-tcg-pocket-sim/tree/main/scripts"&gt;source code here&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;The results looks like this&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-cpp" data-lang="cpp"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="cp"&gt;# Average boosters opened - 205.0471&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="cp"&gt;# Most likely number opened - 250 (0.5076)&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="cp"&gt;# Probability above most common - 0.0789&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="cp"&gt;# Average copies of each card&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nl"&gt;Cynthia&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.4393&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nl"&gt;Spiritomb&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;2.2016&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nl"&gt;Gastrodon&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;2.2031&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="cp"&gt;# Probabilities of card sets&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nl"&gt;Cynthia&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.0116&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nl"&gt;Spiritomb&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.0137&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nl"&gt;Gastrodon&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.0159&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;Cynthia&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;Spiritomb&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.0925&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;Cynthia&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;Gastrodon&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.0928&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;Cynthia&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Gastrodon&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;Spiritomb&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.2265&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;Gastrodon&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;Spiritomb&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.547&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I should expect to open ~205 booster packs before getting all three cards.&lt;/p&gt;&#10;&lt;p&gt;The most likely outcome is I&amp;rsquo;ll pull the 2 one stars and will have to buy the two star, with probability about 50%. The probability of having to open more than 250 packs is only 7.89%&lt;/p&gt;&#10;&lt;p&gt;There’s roughly a 1 in 5 chance of pulling all 3 cards before getting to the required pack points. The probability of pulling none of the cards is so unlikely it didn’t happen in 10,000 simulations (but it&amp;rsquo;s not impossible).&lt;/p&gt;&#10;&lt;p&gt;If we plot a histogram, we get a clearer picture of what’s going on&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="/assets/pokemon-sim-histogram.png" alt="histogram of simulated booster packs expected"&gt;&lt;/p&gt;&#10;&lt;p&gt;There are four clear peaks corresponding to 80, 160, 250, and 330 packs — or 400 pp, 800pp, 1250 pp, and 1650 pp. Those numbers should look familiar.&lt;/p&gt;&#10;&lt;h3 id="head-start"&gt;Head start&lt;/h3&gt;&#10;&lt;p&gt;When I starting this mission I had already opened about 100 boosters (500 pp).&lt;/p&gt;&#10;&lt;p&gt;Taking that into account, the results become&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-cpp" data-lang="cpp"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="cp"&gt;# Average boosters opened - 142.9071&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="cp"&gt;# Most likely number opened - 150 (0.4728)&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="cp"&gt;# Probability above most common - 0.2493&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="cp"&gt;# Average copies of each card&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nl"&gt;Cynthia&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.3124&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nl"&gt;Gastrodon&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;1.5405&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nl"&gt;Spiritomb&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;1.5657&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="cp"&gt;# Probabilities of card sets&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;none&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.0007&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nl"&gt;Spiritomb&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.0464&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nl"&gt;Gastrodon&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.0482&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nl"&gt;Cynthia&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.056&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;Cynthia&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Gastrodon&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;Spiritomb&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.078&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;Cynthia&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;Gastrodon&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.0826&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;Cynthia&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;Spiritomb&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.0911&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;Gastrodon&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;Spiritomb&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.597&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now the expected number of boosters is 145. Adding that to the 100 I already opened comes to 245, which is more than the expected number when starting from zero.&lt;/p&gt;&#10;&lt;p&gt;But as before, I will most likely have to buy the two star card with pack points, and it’s highly likely that I will pull the one star cards in the meantime.&lt;/p&gt;&#10;&lt;h3 id="gotta-catch-em-all"&gt;Gotta catch &amp;rsquo;em all&lt;/h3&gt;&#10;&lt;p&gt;In case you were wondering, the expected number of packs to get all 5 Champion of Sinnoh cards is 215 (1075 pp), which is much less than the 2850 pp required to buy the cards. It’s less even than the cost of just the two star card.&lt;/p&gt;&#10;&lt;p&gt;But that calculation isn’t quite correct — Lucario is only available in the Space Time Smackdown &lt;em&gt;Dialga&lt;/em&gt; boosters, while the rest are in &lt;em&gt;Palkia&lt;/em&gt;. That means, if we only open Palkia boosters, there’s zero chance of pulling Lucario.&lt;/p&gt;&#10;&lt;p&gt;Figuring out the optimal strategy in that case is left as an exercise for the reader.&lt;/p&gt;&#10;&lt;h1 id="conclusion"&gt;Conclusion&lt;/h1&gt;&#10;&lt;p&gt;No matter how we come at the calculation, the most likely outcome is that I’ll have to buy the two star Cynthia with pack points, but there&amp;rsquo;s a good chance of pulling the one star cards. This comes down to two star cards being much rarer than one star cards; the probability of pulling Cynthia in any given pack is only about 1 in 500.&lt;/p&gt;&#10;&lt;p&gt;Since I started drafting this post, I’ve gotten up to 900 pack points, and I managed to pull one of the one star cards (Spiritomb) along the way.&lt;/p&gt;&#10;&lt;p&gt;Re-running the simulation, the expected number of boosters in now down to 85.&lt;/p&gt;&#10;&lt;p&gt;Still some way to go&amp;hellip;&lt;/p&gt;&#10;&lt;p&gt;Chris.&lt;/p&gt;&#10;&lt;p&gt;Oh, and if you want to add me, my user name is ‘oatzy’ and my friend code is &lt;code&gt;0625-2776-5308-5489&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;I’m too much of a coward for Versus battles (PvP), but if you offer me a trade I will offer you something in return, even if I don’t need what you offered.&lt;/p&gt;&#10;</content><author><name>Chris Oates</name></author><category term="maths"/><category term="probability"/><category term="pokemon"/><category term="pokemon tcg pocket"/><summary type="html">&lt;p&gt;When Pokemon first took the world by storm, I was 8 years old. Which is to say, I was the perfect age for it. And I was WAY into it.&lt;/p&gt;&#10;&lt;p&gt;Nearly 30 years later, and &lt;a href="https://oatzy.github.io/2022/05/28/data-structure-pokemon-cards.html"&gt;something&lt;/a&gt; of it is still deeply ingrained in my psyche. So when Pokemon TCG Pocket was released, I was an easy mark.&lt;/p&gt;&#10;&lt;h1 id="secret-mission"&gt;Secret Mission&lt;/h1&gt;&#10;&lt;p&gt;Garchomp is my favourite Pokemon, so when the second expansion — Space Time Smackdown — was release with a full-art Garchomp, I had to have it.&lt;/p&gt;</summary></entry><entry><title type="html">Any Probability with a Dice or Coin</title><link href="https://oatzy.github.io/2024/12/22/any-probability-with-a-dice-or-coin.html" rel="alternate" type="text/html" title="Any Probability with a Dice or Coin"/><published>2024-12-22T18:49:00+00:00</published><updated>2024-12-22T18:49:00+00:00</updated><id>/2024/12/22/any-probability-with-a-dice-or-coin</id><content type="html" xml:base="https://oatzy.github.io/2024/12/22/any-probability-with-a-dice-or-coin.html">&lt;p&gt;I woke up from a dream with a question in my head &amp;ndash; &lt;strong&gt;can we generate any probability with a coin and a six-sided dice?&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s focus on the dice - what probabilities can we generate with a dice roll?&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;1 in 6 is easy, if you roll a &lt;code&gt;1&lt;/code&gt; you win&lt;/li&gt;&#10;&lt;li&gt;for 1 in 2, if the result is even &amp;ndash; &lt;code&gt;2&lt;/code&gt;, &lt;code&gt;4&lt;/code&gt;, or &lt;code&gt;6&lt;/code&gt; &amp;ndash; you win&lt;/li&gt;&#10;&lt;li&gt;for 1 in 3, if the result is divisible by three &amp;ndash; &lt;code&gt;3&lt;/code&gt; or &lt;code&gt;6&lt;/code&gt; &amp;ndash; you win&lt;/li&gt;&#10;&lt;li&gt;1 in 4 is less obvious, but since &lt;code&gt;1/4 = 1/2 * 1/2&lt;/code&gt;, we can roll the dice twice and win if both rolls come up even.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;But what about 1 in 5 ?&lt;/p&gt;&#10;&lt;h1 id="keep-rollin-rollin-rollin-rollin"&gt;Keep rollin&amp;rsquo; rollin&amp;rsquo; rollin&amp;rsquo; rollin'&lt;/h1&gt;&#10;&lt;p&gt;Let&amp;rsquo;s start by stubbornly pretending that the dice only has five side.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;If you roll a &lt;code&gt;1&lt;/code&gt;, you win.&lt;/li&gt;&#10;&lt;li&gt;If you roll &lt;code&gt;2&lt;/code&gt;, &lt;code&gt;3&lt;/code&gt;, &lt;code&gt;4&lt;/code&gt;, or &lt;code&gt;5&lt;/code&gt;, you lose.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Problem solved.&lt;/p&gt;&#10;&lt;p&gt;But wait! What if you roll a &lt;code&gt;6&lt;/code&gt;?&lt;/p&gt;&#10;&lt;p&gt;In that case, let&amp;rsquo;s try rolling again &amp;ndash; same rules apply &amp;ndash; and keep rolling until we win or lose.&lt;/p&gt;&#10;&lt;p&gt;What&amp;rsquo;s the probability of winning?&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;the probability of winning &amp;ndash; rolling a &lt;code&gt;1&lt;/code&gt; &amp;ndash; on the first roll is &lt;code&gt;p(1) = 1/6&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;the probability of winning on the second roll is the probability of rolling a &lt;code&gt;6&lt;/code&gt; on the first roll (&lt;code&gt;1/6&lt;/code&gt;) multiplied by the probability of rolling a &lt;code&gt;1&lt;/code&gt; on the second roll (&lt;code&gt;1/6&lt;/code&gt;)&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;code&gt;p(2) = 1/6 * 1/6 = 1/36&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;the probability of winning on first OR second roll is the sum of the probabilities&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;code&gt;p(1||2) = p(1) + p(2) = 1/6 + 1/36 = 0.19444..&lt;/code&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;the probability of winning on the third roll, following the same logic, is&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;code&gt;p(3) = 1/6 * 1/6 * 1/6 = (1/6)^3 = 1/216&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;the probability of wining on the first, second, or third roll is then&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;code&gt;p(1||2||3) = 1/6 + 1/36 + 1/216 = 0.19907..&lt;/code&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;This is looking promising &amp;ndash; the probability is getting closer and closer to &lt;code&gt;0.2&lt;/code&gt; (&lt;code&gt;= 1/5&lt;/code&gt;)&lt;/p&gt;&#10;&lt;p&gt;So, the probability of winning at all, in any round, is the sum of the probabilities of winning on any of a potentially infinite number of rounds&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;p = p(1) + p(2) + p(3) + ... p(i) + ... + p(inf)&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;img src="/assets/probability/1in5-total.png" alt="1 in 5 probability"&gt;&lt;/p&gt;&#10;&lt;p&gt;This a a &lt;a href="https://en.wikipedia.org/wiki/Geometric_series"&gt;geometric series&lt;/a&gt;, for which there&amp;rsquo;s a simple formula&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="/assets/probability/sum-of-powers.png" alt="sum of powers"&gt;&lt;/p&gt;&#10;&lt;p&gt;And substituting &lt;code&gt;x = 1/6&lt;/code&gt; we get&amp;hellip; &lt;code&gt;p = 1/5&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;tada!&lt;/p&gt;&#10;&lt;p&gt;Granted, this approach could result in rolling dice forever, without ever winning or losing (by rolling infinite &lt;code&gt;6&lt;/code&gt;s).&#10;But the probability of that happening is diminishingly small; the probability of rolling just four &lt;code&gt;6&lt;/code&gt;s in a row is less than 1%&lt;/p&gt;&#10;&lt;h1 id="roll-again"&gt;Roll again&lt;/h1&gt;&#10;&lt;p&gt;Now, we might well wonder: Was this a fluke? Or does this work for other numbers?&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s try for 1 in 4.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;roll &lt;code&gt;1&lt;/code&gt; -&amp;gt; win&lt;/li&gt;&#10;&lt;li&gt;roll &lt;code&gt;2&lt;/code&gt;, &lt;code&gt;3&lt;/code&gt;, or &lt;code&gt;4&lt;/code&gt; -&amp;gt; lose&lt;/li&gt;&#10;&lt;li&gt;roll &lt;code&gt;5&lt;/code&gt;, or &lt;code&gt;6&lt;/code&gt; -&amp;gt; re-roll&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;The probability is calculated the same as before&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;the probability of winning &amp;ndash; rolling a &lt;code&gt;1&lt;/code&gt; &amp;ndash; on the first roll is &lt;code&gt;p(1) = 1/6&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;the probability of winning on the second roll is the probability of a re-roll (&lt;code&gt;2/6 = 1/3&lt;/code&gt;) multiplied by the probability of winning on the second roll (&lt;code&gt;1/6&lt;/code&gt;)&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;code&gt;p(2) = 1/6 * 1/3&lt;/code&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;the probability of winning on the third roll is &lt;code&gt;p(3) = 1/6 * 1/3 * 1/3 = 1/6 * (1/3)^2&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;and so on&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Adding up, this time, we have&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="/assets/probability/1in4-total.png" alt="1 in 4 probability"&gt;&lt;/p&gt;&#10;&lt;p&gt;Just like we wanted.&lt;/p&gt;&#10;&lt;p&gt;[NOTE: this time, the sum is from &lt;code&gt;i=0&lt;/code&gt; rather than &lt;code&gt;i=1&lt;/code&gt;]&lt;/p&gt;&#10;&lt;h1 id="prove-it"&gt;Prove it&lt;/h1&gt;&#10;&lt;p&gt;And since we&amp;rsquo;re on a roll (pun intended), let&amp;rsquo;s see if this always works.&lt;/p&gt;&#10;&lt;p&gt;Suppose we have a dice with &lt;code&gt;N&lt;/code&gt; sides, and we want to roll for a &lt;code&gt;1/r&lt;/code&gt; probability, with integer &lt;code&gt;r &amp;lt;= N&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;Probability of a re-roll is&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="/assets/probability/q-reroll.png" alt="re-roll probability"&gt;&lt;/p&gt;&#10;&lt;p&gt;And following through the same logic as before&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="/assets/probability/1inN-proof.png" alt="1 in N proof"&gt;&lt;/p&gt;&#10;&lt;p&gt;QED&lt;/p&gt;&#10;&lt;h1 id="can-you-take-me-higher"&gt;Can you take me higher&lt;/h1&gt;&#10;&lt;p&gt;So with our six-sided dice, we can get probabilities for &lt;code&gt;1/2&lt;/code&gt; to &lt;code&gt;1/6&lt;/code&gt;. But what about &lt;code&gt;1/7&lt;/code&gt;?&lt;/p&gt;&#10;&lt;p&gt;Our algorithm only lets us represent probabilities &lt;code&gt;1/r&lt;/code&gt; for integer &lt;code&gt;r &amp;lt;= N&lt;/code&gt;, where &lt;code&gt;N=6&lt;/code&gt; for a standard six-sided (d6) dice.&lt;/p&gt;&#10;&lt;p&gt;Sure, we could go up to a dice with more sides, like an octahedral (d8). But I don&amp;rsquo;t have one of those.&lt;/p&gt;&#10;&lt;p&gt;How about this &amp;ndash; roll the d6 dice twice; each roll represents a digit in a two-digit, base-6 number.&lt;/p&gt;&#10;&lt;p&gt;We&amp;rsquo;ll treat &lt;code&gt;6&lt;/code&gt; as zero. So if we roll &lt;code&gt;[2][5]&lt;/code&gt; we have hexary (sexary?) number &lt;code&gt;25&lt;/code&gt; = &lt;code&gt;(2*6) + 5 = 17&lt;/code&gt; in decimal&lt;/p&gt;&#10;&lt;p&gt;Now we can represent 36 values. Can you see where this is going?&lt;/p&gt;&#10;&lt;p&gt;So we roll our dice twice&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;if the result is two &lt;code&gt;6&lt;/code&gt;s &amp;ndash; &lt;code&gt;[0][0]&lt;/code&gt; = decimal &lt;code&gt;0&lt;/code&gt; &amp;ndash; then we win&lt;/li&gt;&#10;&lt;li&gt;if the result is decimal &lt;code&gt;1&lt;/code&gt; to &lt;code&gt;6&lt;/code&gt; &amp;ndash; hexary &lt;code&gt;[0][1]&lt;/code&gt; to &lt;code&gt;[1][0]&lt;/code&gt; &amp;ndash; we lose&lt;/li&gt;&#10;&lt;li&gt;otherwise, re-roll.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;As previously demonstrated, we know this will converge on &lt;code&gt;1/7&lt;/code&gt;. Job done.&lt;/p&gt;&#10;&lt;p&gt;Is this practical? Not really. The re-roll probability in this case is &lt;code&gt;29/36 ~ 80%&lt;/code&gt;, which means potentially a lot of re-rolls.&lt;/p&gt;&#10;&lt;p&gt;But, it does work.&lt;/p&gt;&#10;&lt;h1 id="great-expectations"&gt;Great expectations&lt;/h1&gt;&#10;&lt;p&gt;Actually, how many rolls &lt;em&gt;would&lt;/em&gt; we expect?&lt;/p&gt;&#10;&lt;p&gt;We can think of rolling and re-rolling as a &lt;a href="https://en.wikipedia.org/wiki/Bernoulli_trial"&gt;Bernoulli trial&lt;/a&gt;, where the probability of the trials ending (not re-rolling) is given by &lt;code&gt;p(end) = 1 - q = r/N&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;The &lt;a href="https://www.cut-the-knot.org/Probability/LengthToFirstSuccess.shtml"&gt;expected number of trials&lt;/a&gt; is then given by &lt;code&gt;T = 1/p(end) = N/r&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;For the two dice &lt;code&gt;1/7&lt;/code&gt; example, that comes out to &lt;code&gt;36/7 = 5.1428..&lt;/code&gt; rolls (or &lt;code&gt;10.28..&lt;/code&gt;, since we&amp;rsquo;re rolling two dice for each trial).&lt;/p&gt;&#10;&lt;p&gt;By comparison, the single dice &lt;code&gt;1/5&lt;/code&gt; probability would expect only &lt;code&gt;T = 6/5 = 1.2&lt;/code&gt; rolls&lt;/p&gt;&#10;&lt;p&gt;We can get an improvement on two dice for &lt;code&gt;1/7&lt;/code&gt; by instead pairing the dice with a coin &amp;ndash; flip a coin for the first digit and roll a dice for the second. This gives us 12 possible values and means we expect only &lt;code&gt;12/7 = 1.714..&lt;/code&gt; trials (rolls and flips), which is much more reasonable.&lt;/p&gt;&#10;&lt;h1 id="flippin-heck"&gt;Flippin&amp;rsquo; heck&lt;/h1&gt;&#10;&lt;p&gt;There&amp;rsquo;s question that had been floating around in my head for a while, before the dream &amp;ndash; &lt;strong&gt;can we get a probability of 1 in 3 with one or more coin flips?&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;Following the same algorithm as for the dice, we can flip two coins (or one coin twice). The result is interpreted as a two digit binary number &amp;ndash; heads = &lt;code&gt;0&lt;/code&gt;, tails = &lt;code&gt;1&lt;/code&gt;, giving us 4 possible values.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;If we get two heads &amp;ndash; &lt;code&gt;(0)(0)&lt;/code&gt; &amp;ndash; we win!&lt;/li&gt;&#10;&lt;li&gt;If we get one head and one tail &amp;ndash; &lt;code&gt;(0)(1)&lt;/code&gt; or &lt;code&gt;(1)(0)&lt;/code&gt; (1 or 2 in decimal) &amp;ndash; we lose.&lt;/li&gt;&#10;&lt;li&gt;If we get two tails &amp;ndash; &lt;code&gt;(1)(1)&lt;/code&gt; (decimal 3) &amp;ndash; flip again.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Repeat until the game ends. Surprisingly simple.&lt;/p&gt;&#10;&lt;p&gt;The expected total number of coin flips is &lt;code&gt;2 * N/r = 2 * 4/3 = 2.66..&lt;/code&gt;&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;So there you go - you can generate any probability with a single dice or coin.&lt;/p&gt;&#10;&lt;p&gt;Wait, why are we only half way through this post?&lt;/p&gt;&#10;&lt;h1 id="re-numeration"&gt;Re-numeration&lt;/h1&gt;&#10;&lt;p&gt;All the probabilities we&amp;rsquo;ve looked at so far have been one-in-X. What about higher numerators? Can we get 2-in-5 with a dice?&lt;/p&gt;&#10;&lt;p&gt;If the trick worked for 1/5, why not 2/5?&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;roll a &lt;code&gt;1&lt;/code&gt; or &lt;code&gt;2&lt;/code&gt; -&amp;gt; win&lt;/li&gt;&#10;&lt;li&gt;roll &lt;code&gt;3&lt;/code&gt;, &lt;code&gt;4&lt;/code&gt;, &lt;code&gt;5&lt;/code&gt; -&amp;gt; lose&lt;/li&gt;&#10;&lt;li&gt;roll &lt;code&gt;6&lt;/code&gt; -&amp;gt; re-roll&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Now&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;the probability of winning on the first roll &amp;ndash; rolling &lt;code&gt;1&lt;/code&gt; or &lt;code&gt;2&lt;/code&gt; &amp;ndash; is &lt;code&gt;p(1) = 2/6&lt;/code&gt; (&lt;code&gt;= 1/3&lt;/code&gt;)&lt;/li&gt;&#10;&lt;li&gt;the probability of a re-roll is &lt;code&gt;1/6&lt;/code&gt;, so the probability of winning on the second roll is &lt;code&gt;p(2) = 1/6 * 1/3&lt;/code&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;You should know the words by now&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="/assets/probability/2in5-total.png" alt="2 in 5 probability"&gt;&lt;/p&gt;&#10;&lt;p&gt;Likewise, if we have an N sided dice and want probability &lt;code&gt;p = a/b&lt;/code&gt;, where integers &lt;code&gt;0 &amp;lt;= a &amp;lt; b &amp;lt;= N&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;The probability of winning on the first roll is &lt;code&gt;a/N&lt;/code&gt; and the probability of a re-roll is &lt;code&gt;q = (N - b) / N&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;So the total probability of winning is&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="/assets/probability/ainb-proof.png" alt="rational probability proof"&gt;&lt;/p&gt;&#10;&lt;p&gt;QED again.&lt;/p&gt;&#10;&lt;p&gt;Okay, now we&amp;rsquo;ve covered everything. Right?&lt;/p&gt;&#10;&lt;h1 id="stop-making-sense"&gt;Stop making sense&lt;/h1&gt;&#10;&lt;p&gt;&lt;em&gt;&amp;ldquo;But wait&amp;hellip;&amp;rdquo;&lt;/em&gt;, you say, &lt;em&gt;&amp;ldquo;what about irrational probabilities?&amp;rdquo;&lt;/em&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;em&gt;&amp;ldquo;Oh&amp;hellip;&amp;rdquo;&lt;/em&gt;, I say, &lt;em&gt;&amp;ldquo;right&amp;hellip;&amp;rdquo;&lt;/em&gt; :/&lt;/p&gt;&#10;&lt;p&gt;An irrational probability would be something like &lt;code&gt;1/pi&lt;/code&gt; or &lt;code&gt;1/e&lt;/code&gt;. Can we roll that with a six-sided dice?&lt;/p&gt;&#10;&lt;p&gt;So far, we&amp;rsquo;ve been assuming the probabilities are the same each round &amp;ndash; for example, if we roll a &lt;code&gt;1&lt;/code&gt; we win, if we roll a &lt;code&gt;6&lt;/code&gt; we re-roll, regardless of how many rolls we&amp;rsquo;ve already thrown.&lt;/p&gt;&#10;&lt;p&gt;What if we change things up. Let&amp;rsquo;s stick with re-rolling when we get a &lt;code&gt;6&lt;/code&gt;, but vary the win condition on each round.&lt;/p&gt;&#10;&lt;p&gt;For example, suppose we did the following&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;if we roll &lt;code&gt;1&lt;/code&gt; on the first round we win&lt;/li&gt;&#10;&lt;li&gt;if we roll &lt;code&gt;1&lt;/code&gt;, &lt;code&gt;2&lt;/code&gt;, &lt;code&gt;3&lt;/code&gt;, &lt;code&gt;4&lt;/code&gt;, or &lt;code&gt;5&lt;/code&gt; on the second round we win&lt;/li&gt;&#10;&lt;li&gt;if we roll &lt;code&gt;1&lt;/code&gt; or &lt;code&gt;2&lt;/code&gt; on the third round we win&lt;/li&gt;&#10;&lt;li&gt;and so on&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;The probability is then&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="/assets/probability/1inpi-partial.png" alt="1 in pi probability"&gt;&lt;/p&gt;&#10;&lt;p&gt;And we can see this inching upwards&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;p(1) = 0.1666..&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;p(1||2) = 0.3055..&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;p(1||2||3) = 0.3148..&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;p(1||2||3||4) = 0.3179..&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;...&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;towards &lt;code&gt;p = 0.3183... = 1/pi&lt;/code&gt;&lt;/p&gt;&#10;&lt;h1 id="all-your-base"&gt;All your base&lt;/h1&gt;&#10;&lt;p&gt;We can generalise this approach like so &amp;ndash; we have an N sided dice, and to win on the &lt;code&gt;i-th&lt;/code&gt; throw, we need to roll &lt;code&gt;ai&lt;/code&gt; or lower, where &lt;code&gt;ai&lt;/code&gt; is an integer &lt;code&gt;0 &amp;lt;= ai &amp;lt; N&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;The total probability of winning is then&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="/assets/probability/baseN-prob.png" alt="base N probability"&gt;&lt;/p&gt;&#10;&lt;p&gt;And what we&amp;rsquo;re describing here is actually the base-N representation of &lt;code&gt;p&lt;/code&gt;. It&amp;rsquo;s correct by construction, so no proof required.&lt;/p&gt;&#10;&lt;p&gt;The coefficients &lt;code&gt;ai&lt;/code&gt; can be calculated like so&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;tobase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;divmod&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# list(itertools.islice(tobase(1/math.pi, 6), 10))&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;(for p &amp;lt; 1)&lt;/p&gt;&#10;&lt;p&gt;So, for example, the first 10 values of &lt;code&gt;ai&lt;/code&gt; for &lt;code&gt;1/pi&lt;/code&gt; in base-6 are&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;...&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and for &lt;code&gt;1/e&lt;/code&gt; in base-6&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;...&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The same works for coin flips as well &amp;ndash; &lt;code&gt;1/pi&lt;/code&gt; in base-2 is&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;...&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Is this practical &amp;ndash; memorising an infinite sequence of coefficients? Almost certainly not.&lt;/p&gt;&#10;&lt;h1 id="sixes-and-sevens"&gt;Sixes and sevens&lt;/h1&gt;&#10;&lt;p&gt;Incidentally, this approach does also works for rational numbers.&lt;/p&gt;&#10;&lt;p&gt;And it gives us an interesting, alternative way of getting &lt;code&gt;1/7&lt;/code&gt; from a dice roll.&lt;/p&gt;&#10;&lt;p&gt;The coefficients (&lt;code&gt;ai&lt;/code&gt;) for &lt;code&gt;1/7&lt;/code&gt; in base 6 are&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;...&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;alternating &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;5&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;In terms of dice rolls, &lt;code&gt;0&lt;/code&gt; means we lose if we roll anything other than &lt;code&gt;6&lt;/code&gt; (re-roll), and &lt;code&gt;5&lt;/code&gt; means we win if we roll anything other than &lt;code&gt;6&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;This translate to:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Roll the dice until you get anything other than &lt;code&gt;6&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;If you rolled an odd number of times, you lose.&lt;/li&gt;&#10;&lt;li&gt;If you rolling an even number of times, you win.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;For example, if you rolled &lt;code&gt;6, 6, 3&lt;/code&gt;, then you stopped on the third roll, which is odd, so you lose. Sorry.&lt;/p&gt;&#10;&lt;p&gt;But if you rolled &lt;code&gt;6, 1&lt;/code&gt;, that&amp;rsquo;s an even number of rolls, so you win. Woo!&lt;/p&gt;&#10;&lt;p&gt;This is much easier to comprehend than the previously discussed &lt;code&gt;1/7&lt;/code&gt; methods, and it has an expected number of rolls &lt;code&gt;T = 6/5 = 1.2&lt;/code&gt;. So it would be my preferred method.&lt;/p&gt;&#10;&lt;p&gt;There&amp;rsquo;s a similarly nice, repeating pattern for &lt;code&gt;1/7&lt;/code&gt; in base 2&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;...&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This means we can flip a coin until we gets a heads, and if the number of flips was divisible by 3, we win.&lt;/p&gt;&#10;&lt;h1 id="back-to-dreaming"&gt;Back to dreaming&lt;/h1&gt;&#10;&lt;p&gt;Now are we done?&lt;/p&gt;&#10;&lt;p&gt;What about imaginary numbers? Can we do imaginary probabilities?&lt;/p&gt;&#10;&lt;p&gt;&amp;hellip;&lt;/p&gt;&#10;&lt;p&gt;Merry Christmas.&lt;/p&gt;&#10;&lt;p&gt;Chris.&lt;/p&gt;&#10;&lt;p&gt;[yes, I know the singular of &amp;lsquo;dice&amp;rsquo; is &amp;lsquo;die&amp;rsquo;]&lt;/p&gt;&#10;</content><author><name>Chris Oates</name></author><category term="maths"/><category term="probability"/><summary type="html">&lt;p&gt;I woke up from a dream with a question in my head &amp;ndash; &lt;strong&gt;can we generate any probability with a coin and a six-sided dice?&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;Let&amp;rsquo;s focus on the dice - what probabilities can we generate with a dice roll?&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;1 in 6 is easy, if you roll a &lt;code&gt;1&lt;/code&gt; you win&lt;/li&gt;&#10;&lt;li&gt;for 1 in 2, if the result is even &amp;ndash; &lt;code&gt;2&lt;/code&gt;, &lt;code&gt;4&lt;/code&gt;, or &lt;code&gt;6&lt;/code&gt; &amp;ndash; you win&lt;/li&gt;&#10;&lt;li&gt;for 1 in 3, if the result is divisible by three &amp;ndash; &lt;code&gt;3&lt;/code&gt; or &lt;code&gt;6&lt;/code&gt; &amp;ndash; you win&lt;/li&gt;&#10;&lt;li&gt;1 in 4 is less obvious, but since &lt;code&gt;1/4 = 1/2 * 1/2&lt;/code&gt;, we can roll the dice twice and win if both rolls come up even.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;But what about 1 in 5 ?&lt;/p&gt;</summary></entry><entry><title type="html">Every film I ever saw - data mining myself</title><link href="https://oatzy.github.io/2024/06/06/every-film-i-ever-saw.html" rel="alternate" type="text/html" title="Every film I ever saw - data mining myself"/><published>2024-06-06T19:56:00+00:00</published><updated>2024-06-06T19:56:00+00:00</updated><id>/2024/06/06/every-film-i-ever-saw</id><content type="html" xml:base="https://oatzy.github.io/2024/06/06/every-film-i-ever-saw.html">&lt;p&gt;I signed up for &lt;a href="https://letterboxd.com/oatzy/"&gt;Letterboxd&lt;/a&gt;.&lt;/p&gt;&#10;&lt;h1 id="trakt"&gt;trakt&lt;/h1&gt;&#10;&lt;p&gt;One of the first options, on creating a letterboxd account, is importing data from other services - one of them being &lt;a href="https://trakt.tv/"&gt;trakt&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;I don&amp;rsquo;t use trakt directly. For many years, I&amp;rsquo;ve been using &lt;a href="https://www.seriesgui.de/"&gt;SeriesGuide&lt;/a&gt; to keep track of TV shows. I used this in combination with trakt because I could then use the trakt api to get a list of new episodes &amp;rsquo;today&amp;rsquo; for &lt;a href="https://oatzy.github.io/2020/05/17/encounter-with-rust-safety.html"&gt;completely legal reasons&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;SeriesGuide also lets you track films.&lt;/p&gt;&#10;&lt;p&gt;So I &lt;a href="https://github.com/anoopsankar/Trakt2Letterboxd"&gt;exported my data&lt;/a&gt; and imported it into Letterboxd - roughly 950 films&lt;/p&gt;&#10;&lt;p&gt;And what&amp;rsquo;s interesting about this is trakt had recorded &lt;em&gt;when&lt;/em&gt; I&amp;rsquo;d watched each film, and Letterboxd displays this in a &lt;a href="https://letterboxd.com/oatzy/films/diary/"&gt;&amp;lsquo;diary&amp;rsquo;&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;This is quite pleasing.&lt;/p&gt;&#10;&lt;p&gt;The only problem is, the earliest film I had recorded in trakt was &lt;a href="https://letterboxd.com/film/interstellar/"&gt;Interstellar&lt;/a&gt; in November 2014.&lt;/p&gt;&#10;&lt;p&gt;I could do better. I could go farther.&lt;/p&gt;&#10;&lt;p&gt;Too far? Who&amp;rsquo;s to say&amp;hellip;&lt;/p&gt;&#10;&lt;h1 id="etickets"&gt;eTickets&lt;/h1&gt;&#10;&lt;p&gt;There were a couple films - &lt;a href="https://letterboxd.com/film/spider-man-no-way-home/"&gt;Spider-man: No Way Home&lt;/a&gt; and &lt;a href="https://letterboxd.com/film/venom-let-there-be-carnage/"&gt;Venom: Let There be carnage&lt;/a&gt; - which I hadn&amp;rsquo;t logged. Luckily, I have etickets, so just had to search my emails to get the exact date.&lt;/p&gt;&#10;&lt;p&gt;But I only started buying tickets online in 2021, when movies started to come back after covid&lt;/p&gt;&#10;&lt;p&gt;[the first film I saw, post-covid, was &lt;a href="https://letterboxd.com/film/black-widow-2021/"&gt;Black Widow&lt;/a&gt;]&lt;/p&gt;&#10;&lt;h1 id="ticket-stubs"&gt;Ticket stubs&lt;/h1&gt;&#10;&lt;p&gt;My next thought was&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;&lt;em&gt;you know&amp;hellip; I&amp;rsquo;m the sort of person who would keep old ticket stubs; and I bet I know where they are&amp;hellip;&lt;/em&gt;&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&lt;p&gt;And reader, I am, and I did&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="/assets/ticket_stubs.jpg" alt="A bundle of ticket stubs"&gt;&lt;/p&gt;&#10;&lt;p&gt;I was surprised by how far back they go - the oldest is for &lt;a href="https://letterboxd.com/film/the-world-is-not-enough/"&gt;The World is Not Enough&lt;/a&gt; in 1999.&lt;/p&gt;&#10;&lt;p&gt;The most recent is for &lt;a href="https://letterboxd.com/film/the-amazing-spider-man-2/"&gt;Amazing Spider-Man 2&lt;/a&gt; in April 2014.&lt;/p&gt;&#10;&lt;p&gt;I was also surprised by some of the films, for example I have no memory of seeing &lt;a href="https://letterboxd.com/film/lilo-stitch/"&gt;Lilo &amp;amp; Stitch&lt;/a&gt; at the cinema, but I have a ticket stub that says otherwise.&lt;/p&gt;&#10;&lt;p&gt;On the other hand, I was disappointed by how much was missing. I saw &lt;a href="https://letterboxd.com/film/pokemon-the-movie-2000/"&gt;Pokemon: The Movie 2000&lt;/a&gt; at the cinema - I have the promo cards to prove it - but sadly no ticket stub to say when.&lt;/p&gt;&#10;&lt;h1 id="notion"&gt;Notion&lt;/h1&gt;&#10;&lt;p&gt;While looking over my watch history from trakt, I noticed a weird empty spot from November-December 2022. This didn&amp;rsquo;t look right, because I&amp;rsquo;m in the habit of watching movies every weekend.&lt;/p&gt;&#10;&lt;p&gt;Maybe I was lazy those two months, or maybe trakt was having some issues? I dunno.&lt;/p&gt;&#10;&lt;p&gt;I started using &lt;a href="https://www.notion.so/"&gt;notion&lt;/a&gt; for note keeping in 2020, and I had a movie watching list in there. And when I watched a movie, I would check a box to hide it.&lt;/p&gt;&#10;&lt;p&gt;Now, I didn&amp;rsquo;t record when exactly I watched the films, but notion does auto-track the last edit time on each item - such as when a checkbox is checked.&lt;/p&gt;&#10;&lt;p&gt;I was a little lax about when I checked the box on notion - sometimes it would be days later - but it was enough to tell me which films I was missing from that period.&lt;/p&gt;&#10;&lt;p&gt;[I also did star ratings in notion, which I could manually copy across]&lt;/p&gt;&#10;&lt;h1 id="netflix"&gt;Netflix&lt;/h1&gt;&#10;&lt;p&gt;Netflix keeps a &lt;a href="https://help.netflix.com/en/node/101917"&gt;watch history&lt;/a&gt;, and even better lets you download it as a &lt;a href="https://en.wikipedia.org/wiki/Comma-separated_values"&gt;CSV&lt;/a&gt; file&lt;/p&gt;&#10;&lt;p&gt;But not a CSV that can be imported to letterboxd.&lt;/p&gt;&#10;&lt;p&gt;It only tells you title and watch date, and annoyingly combines tv shows and movies.&lt;/p&gt;&#10;&lt;p&gt;The quick and dirty work around was to &lt;a href="https://en.wikipedia.org/wiki/Grep"&gt;grep&lt;/a&gt; out words like &amp;ldquo;Episode&amp;rdquo;, &amp;ldquo;Season&amp;rdquo;, &amp;ldquo;Series&amp;rdquo;&lt;/p&gt;&#10;&lt;p&gt;Starting from the bottom, the earliest entry was &lt;a href="https://letterboxd.com/film/cloudy-with-a-chance-of-meatballs/"&gt;Cloudy With a Chance of Meatballs&lt;/a&gt; in September 2014&lt;/p&gt;&#10;&lt;p&gt;I only had to add a few entries from 2014 before I hit the movies I&amp;rsquo;d recorded in trakt.&lt;/p&gt;&#10;&lt;h1 id="prime-video"&gt;Prime Video&lt;/h1&gt;&#10;&lt;p&gt;Amazon also keeps a watch history, but you have to make a &lt;a href="https://www.amazon.co.uk/hz/privacy-central/data-requests/preview.html"&gt;formal request&lt;/a&gt; and wait a couple of days for the download.&lt;/p&gt;&#10;&lt;p&gt;It&amp;rsquo;s CSV again, and with a similar issue as netflix of mixing tv and movies. And to make matters worse, it seems to record trailers, including the ones that auto-play in the app&lt;/p&gt;&#10;&lt;p&gt;I only got Amazon Prime when I entered full time employment (end of 2015), and 2015 onwards I had in trakt. So most of it was already covered.&lt;/p&gt;&#10;&lt;p&gt;There were a couple of early films I hadn&amp;rsquo;t logged. The first film I watched on Prime was &lt;a href="https://letterboxd.com/film/it-follows/"&gt;It Follows&lt;/a&gt; on Boxing Day 2015.&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;ve watched films on other streaming services, but none before 2015. I did have to look up one on &lt;a href="https://www.crunchyroll.com/"&gt;Crunchyroll&lt;/a&gt;, which sadly does not provide a downloadable history.&lt;/p&gt;&#10;&lt;h1 id="lovefilm"&gt;LoveFilm&lt;/h1&gt;&#10;&lt;p&gt;&amp;hellip;was a DVD rental service, like the UK equivalent of the original incarnation of netflix.&lt;/p&gt;&#10;&lt;p&gt;I signed up for an account in 2010. &lt;a href="https://en.wikipedia.org/wiki/LoveFilm"&gt;LoveFilm&lt;/a&gt; was later bought out by Amazon, who ultimately discontinued the service in 2017&lt;/p&gt;&#10;&lt;p&gt;Unfortunately, I don&amp;rsquo;t have any record of what films I rented or when. I searched my email and found two &amp;ldquo;Your next rental is on the way&amp;hellip;&amp;rdquo; messages (&lt;a href="https://letterboxd.com/film/twelve-monkeys/"&gt;Twelve Monkeys&lt;/a&gt; and &lt;a href="https://letterboxd.com/film/creation/"&gt;Creation&lt;/a&gt;)&lt;/p&gt;&#10;&lt;p&gt;Apparently, I deleted all the subsequent emails.&lt;/p&gt;&#10;&lt;p&gt;IIRC, my subscription was 3 DVDs a month, and I had the account ~7 years - totalling about 250 films, which is a pretty major loss of data.&lt;/p&gt;&#10;&lt;p&gt;When I was requesting my Amazon data, I also enquired about my LoveFilm rental history. But they just sent me another copy of my prime video data (which doesn&amp;rsquo;t include Lovefilm). So one has to assume that data no longer exists.&lt;/p&gt;&#10;&lt;h1 id="foursquare"&gt;Foursquare&lt;/h1&gt;&#10;&lt;p&gt;Clutching at straws, I was starting to wonder if I could use my phone&amp;rsquo;s location data (google maps) to figure out when I visited (or was near) a cinema. Then I remembered I had something even better.&lt;/p&gt;&#10;&lt;p&gt;There was a period, 2010-2014, when I used &lt;a href="https://foursquare.com/city-guide"&gt;foursquare&lt;/a&gt; to record everywhere I went - including cinema visits, and including what film I saw&lt;/p&gt;&#10;&lt;p&gt;(2014 conveniently being when I started tracking films in SeriesGuide, more or less)&lt;/p&gt;&#10;&lt;p&gt;And the data still exists on the foursquare website (tho it was hard to find the right login page from google). Once I reset my password, it was a simple matter of filtering on &lt;em&gt;&amp;ldquo;Category: Movie Theatre&amp;rdquo;&lt;/em&gt;.&lt;/p&gt;&#10;&lt;p&gt;But it turned out I didn&amp;rsquo;t log the specific film for my first 3 recorded cinema visits.&lt;/p&gt;&#10;&lt;p&gt;For the first one, I added the comment &lt;em&gt;&amp;ldquo;Mind suitably braced for being blown&amp;hellip;&amp;rdquo;&lt;/em&gt; and safely assumed this was &lt;a href="https://letterboxd.com/film/inception/"&gt;Inception&lt;/a&gt; (it aligned with the release date)&lt;/p&gt;&#10;&lt;p&gt;Similarly, I remembered seeing &lt;a href="https://letterboxd.com/film/source-code/"&gt;Source Code&lt;/a&gt; around this time, and it wasn&amp;rsquo;t mentioned in any of my other check-ins. And again the release date lines up.&lt;/p&gt;&#10;&lt;p&gt;For the last one I wasn&amp;rsquo;t sure what it could be. I had a scroll through old blog posts from around that time for clues, and lo and behold - &amp;ldquo;&lt;a href="https://letterboxd.com/film/tron-legacy/"&gt;Tron Legacy&lt;/a&gt;: &lt;a href="https://oatzy.github.io/2011/01/15/tron-legacy-review.html"&gt;A Review&lt;/a&gt;&amp;rdquo;&lt;/p&gt;&#10;&lt;p&gt;Incidentally, there are a couple other old posts on this blog &lt;a href="https://oatzy.github.io/2010/08/08/inception-review.html"&gt;for&lt;/a&gt; &lt;a href="https://oatzy.github.io/2010/08/15/handful-of-film-reviews.html"&gt;film&lt;/a&gt; &lt;a href="https://oatzy.github.io/2010/08/27/good-departed-pilgrim-flew-over.html"&gt;reviews&lt;/a&gt;&lt;/p&gt;&#10;&lt;h1 id="twitter"&gt;Twitter&lt;/h1&gt;&#10;&lt;p&gt;Between 2009 and 2015, I was a prolific tweeter, so it seemed likely I would have mentioned watching a bunch of films.&lt;/p&gt;&#10;&lt;p&gt;To check, I downloaded my twitter data. I can find quite a few relevant tweets by grepping: &amp;lsquo;watch&amp;rsquo; (watched, watching), &amp;lsquo;cinema&amp;rsquo;, &amp;lsquo;film&amp;rsquo;, &amp;lsquo;movie&amp;rsquo;, &amp;lsquo;see&amp;rsquo; (seen), &amp;lsquo;saw&amp;rsquo; &amp;hellip;&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code&gt;Watched &amp;#39;Non Stop&amp;#39;. Was better than I expected. As if any movie where Liam Neeson plays an action hero could be bad.&#10;-- Sat Aug 16 21:55:48 +0000 2014&#10;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;[I guess a lot can &lt;a href="https://letterboxd.com/film/retribution-2023/"&gt;change&lt;/a&gt; in 10 years :p]&lt;/p&gt;&#10;&lt;p&gt;But this isn&amp;rsquo;t foolproof, it&amp;rsquo;s hard to pick out all mentions or allusions to films&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code&gt;Who is this old joker? #BucketList&#10;-- Sat Sep 11 21:06:15 +0000 2010&#10;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Maybe one could use machine learning to pick out movie titles.&lt;/p&gt;&#10;&lt;p&gt;Then there&amp;rsquo;s this spicy take&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code&gt;I&amp;#39;ve got nothing against subtitled film, but they&amp;#39;re a pain in the arse if you like to watch films while you eat. #RemakeAllTheForeignFilms&#10;-- Sun Feb 26 13:59:20 +0000 2012&#10;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;I remembered I was referring to &lt;a href="https://letterboxd.com/film/the-extraordinary-adventures-of-adele-blanc-sec/"&gt;The Extraordinary Adventures of Adele Blac-Sec&lt;/a&gt; - or as I typed it into google, since I couldn&amp;rsquo;t remember the title, &lt;em&gt;&amp;ldquo;french comic movie adel&amp;rdquo;&lt;/em&gt;.&lt;/p&gt;&#10;&lt;p&gt;Side note: one set of tweets shows me starting to watch &lt;a href="https://letterboxd.com/film/transformers/"&gt;Michael Bay&amp;rsquo;s Transformers&lt;/a&gt;, and giving up after ~1 hour. Should that count?&lt;/p&gt;&#10;&lt;h1 id="myspace"&gt;MySpace&lt;/h1&gt;&#10;&lt;p&gt;Before twitter, I had a MySpace blog, and from 2007-2008 I updated it almost daily.&lt;/p&gt;&#10;&lt;p&gt;In a way, the blog was like a proto-twitter, in that it was a collection of disconnected thoughts, autobiography, and random quotes and song lyrics.&lt;/p&gt;&#10;&lt;p&gt;I kept a backup of all my posts when MySpace went out of fashion; the live blog no longer exists.&lt;/p&gt;&#10;&lt;p&gt;So I fetched the backup and, as with the tweets, grepped for pertinent words&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code&gt;2 Aug 2007&#10; [Another chapter of my pathetic life]&#10;&#10; I&amp;#39;m disinclined to acquiesce to your request.&#10;&#10; Means no.&#10;&#10; Due to the lack of decent TV before the setting of the sun, I&amp;#39;ve rediscovered my DVD collection.&#10; [I&amp;#39;ve got perhaps more Johnny Depp DVDs than is normal for a boy of my age]&#10; Today I watched &amp;#39;Pirates of the Caribbean: Curse of the Balck Pearl&amp;#39; [longest name ever], and tomorrow I intend to watch &amp;#39;Deadman&amp;#39;s Chest&amp;#39;.&#10;&#10; Other movies I&amp;#39;ve watched over the past week [most on TV]:&#10; &amp;#39;Edward Scissorhand&amp;#39;, &amp;#39;Charlie&amp;#39;s Angels&amp;#39;, &amp;#39;Secretary&amp;#39;, the back end of Napolean &amp;#39;Dynamite&amp;#39;, &amp;#39;Charlie and the Chocolate Factory&amp;#39;, &amp;#39;Constantine&amp;#39;, &amp;#39;Dodge Ball&amp;#39;...&#10; can&amp;#39;t think of any others off the top of my head.&#10;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Frustratingly, a few time I mention going to the cinema, without saying which film I saw&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code&gt;I went to the movies. But I don&amp;#39;t need to tell you about that, &amp;#39;cause most of my &amp;#39;core&amp;#39; readers were there.&#10;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;[Reading back over those blogs, I was surprised by how often I wrote about getting drunk. Ah, to be 18 again.]&lt;/p&gt;&#10;&lt;h1 id="memory"&gt;Memory?&lt;/h1&gt;&#10;&lt;p&gt;It&amp;rsquo;s frustrating, knowing you saw a film at the cinema, but not being able to pin down an actual date.&lt;/p&gt;&#10;&lt;p&gt;I mean, it&amp;rsquo;s going to be within, say, 2 weeks of release. But I&amp;rsquo;m not sure I can allow myself that big a margin of error.&lt;/p&gt;&#10;&lt;h1 id="compromise"&gt;Compromise&lt;/h1&gt;&#10;&lt;p&gt;Of course, I&amp;rsquo;m never going to be able to figure out &lt;em&gt;when&lt;/em&gt; I saw every film I ever saw.&lt;/p&gt;&#10;&lt;p&gt;Beyond a certain point I just have to settle for logging that I saw a film &amp;lsquo;at some point&amp;rsquo;.&lt;/p&gt;&#10;&lt;p&gt;Even this is harder than it seems.&lt;/p&gt;&#10;&lt;p&gt;Given a specific film, it&amp;rsquo;s fairly easy to say whether or not I&amp;rsquo;ve seen it. So one approach was to browse through popular films, directors, actors. But there are going to be things you miss from this approach - the unpopular, the obscure.&lt;/p&gt;&#10;&lt;p&gt;The harder approach is trying to randomly remember films I&amp;rsquo;ve seen.&lt;/p&gt;&#10;&lt;p&gt;[&lt;em&gt;&amp;ldquo;Ooh, what was that &lt;a href="https://letterboxd.com/film/byzantium/"&gt;vampire film&lt;/a&gt; with Saoirse Ronan?&amp;rdquo;&lt;/em&gt;]&lt;/p&gt;&#10;&lt;p&gt;This mostly works by association - I&amp;rsquo;ve seen this film, oh that reminds me of this other film.&lt;/p&gt;&#10;&lt;p&gt;I&amp;rsquo;ve reached the point where I think I&amp;rsquo;ve covered maybe 99% - I struggle to think of new ones.&lt;/p&gt;&#10;&lt;p&gt;Then occasionally I&amp;rsquo;ll be like &lt;em&gt;&amp;ldquo;wait, how did I forget &lt;a href="https://letterboxd.com/film/who-framed-roger-rabbit/"&gt;Who Framed Roger Rabbit?&lt;/a&gt;&amp;rdquo;&lt;/em&gt;&lt;/p&gt;&#10;&lt;h1 id="fools-errand"&gt;Fool&amp;rsquo;s Errand&lt;/h1&gt;&#10;&lt;p&gt;One thing I&amp;rsquo;ve learned from the films I had concretely recorded - there are films I&amp;rsquo;ve seen that I have no memory of seeing. Which means there are probably films I don&amp;rsquo;t remember, which I don&amp;rsquo;t have any record of.&lt;/p&gt;&#10;&lt;p&gt;And if you don&amp;rsquo;t remember seeing a film, does it really count?&lt;/p&gt;&#10;&lt;p&gt;To date, I&amp;rsquo;ve managed to log ~1,800 films, of which ~1,200 have a definitive watch date. So I managed to pin down ~250 films in addition to those from trakt.&lt;/p&gt;&#10;&lt;p&gt;Which is not too shabby. Not an entirely fruitless endeavour.&lt;/p&gt;&#10;&lt;p&gt;Chris.&lt;/p&gt;&#10;&lt;p&gt;[It really is a shame I couldn&amp;rsquo;t get that LoveFilm data]&lt;/p&gt;&#10;</content><author><name>Chris Oates</name></author><category term="biography"/><category term="data"/><category term="movies"/><summary type="html">&lt;p&gt;I signed up for &lt;a href="https://letterboxd.com/oatzy/"&gt;Letterboxd&lt;/a&gt;.&lt;/p&gt;&#10;&lt;h1 id="trakt"&gt;trakt&lt;/h1&gt;&#10;&lt;p&gt;One of the first options, on creating a letterboxd account, is importing data from other services - one of them being &lt;a href="https://trakt.tv/"&gt;trakt&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;I don&amp;rsquo;t use trakt directly. For many years, I&amp;rsquo;ve been using &lt;a href="https://www.seriesgui.de/"&gt;SeriesGuide&lt;/a&gt; to keep track of TV shows. I used this in combination with trakt because I could then use the trakt api to get a list of new episodes &amp;rsquo;today&amp;rsquo; for &lt;a href="https://oatzy.github.io/2020/05/17/encounter-with-rust-safety.html"&gt;completely legal reasons&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;SeriesGuide also lets you track films.&lt;/p&gt;</summary></entry><entry><title type="html">My hat contains a hidden message</title><link href="https://oatzy.github.io/2024/03/17/hat-contains-hidden-message.html" rel="alternate" type="text/html" title="My hat contains a hidden message"/><published>2024-03-17T16:49:00+00:00</published><updated>2024-03-17T16:49:00+00:00</updated><id>/2024/03/17/hat-contains-hidden-message</id><content type="html" xml:base="https://oatzy.github.io/2024/03/17/hat-contains-hidden-message.html">&lt;p&gt;I shaved my head.&lt;/p&gt;&#10;&lt;p&gt;My hair&amp;rsquo;s been getting thinner for a while now, so I thought I&amp;rsquo;d try going all in.&lt;/p&gt;&#10;&lt;p&gt;I’m still getting used to it.&lt;/p&gt;&#10;&lt;p&gt;But one thing I &lt;em&gt;did&lt;/em&gt; expect, was that my head would feel colder now. So I needed a hat.&lt;/p&gt;&#10;&lt;p&gt;I looked over my save crochet patterns and found this one - &lt;a href="https://www.hanjancrochet.com/free-c2c-crochet-hat-patten/"&gt;Widcombe C2C crochet hat&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;It uses a crochet technique called ‘corner-to-corner’ (c2c) - effectively the fabric is made up of squares, worked in diagonal rows.&lt;/p&gt;&#10;&lt;p&gt;The design as written is okay, but a little generic. I wanted something more meaningful.&lt;/p&gt;&#10;&lt;p&gt;The c2c effectively gives us a grid, and in the original design the middle band is a repeating pattern of 6x10 square blocks.&lt;/p&gt;&#10;&lt;p&gt;So the question was, what could I do with this?&lt;/p&gt;&#10;&lt;p&gt;Well a row of 6 squares gives us 6 bits, allowing us to represent 64 values - more than enough to encode characters of the (latin) alphabet.&lt;/p&gt;&#10;&lt;p&gt;Meanwhile we have 10 rows, and it just so happens that my name contains 10 letters - CHRIS OATES&lt;/p&gt;&#10;&lt;p&gt;In fact, we only need 5 bits to represent the alphabet, so we have one spare. I considered leaving it blank, or using it to represent uppercase/lowercase. But none of those looked very good, so I just used repeating blocks of 5x10.&lt;/p&gt;&#10;&lt;p&gt;The complete design looks like this&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="/assets/binary_hat/hat-pattern.jpg" alt="Hat design"&gt;&lt;/p&gt;&#10;&lt;p&gt;And here’s the completed hat&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="/assets/binary_hat/finished-hat.jpg" alt="Completed hat"&gt;&lt;/p&gt;&#10;&lt;p&gt;Following the pattern diagonally was&amp;hellip; fun.&lt;/p&gt;&#10;&lt;p&gt;But at least my head isn&amp;rsquo;t cold anymore.&lt;/p&gt;&#10;&lt;p&gt;Chris.&lt;/p&gt;&#10;</content><author><name>Chris Oates</name></author><category term="crochet"/><category term="maths"/><category term="binary"/><category term="design"/><summary type="html">&lt;p&gt;I shaved my head.&lt;/p&gt;&#10;&lt;p&gt;My hair&amp;rsquo;s been getting thinner for a while now, so I thought I&amp;rsquo;d try going all in.&lt;/p&gt;&#10;&lt;p&gt;I’m still getting used to it.&lt;/p&gt;&#10;&lt;p&gt;But one thing I &lt;em&gt;did&lt;/em&gt; expect, was that my head would feel colder now. So I needed a hat.&lt;/p&gt;&#10;&lt;p&gt;I looked over my save crochet patterns and found this one - &lt;a href="https://www.hanjancrochet.com/free-c2c-crochet-hat-patten/"&gt;Widcombe C2C crochet hat&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;It uses a crochet technique called ‘corner-to-corner’ (c2c) - effectively the fabric is made up of squares, worked in diagonal rows.&lt;/p&gt;</summary></entry><entry><title type="html">Hidden messages and an optimal ternary scarf</title><link href="https://oatzy.github.io/2024/01/20/hidden-message-ternary-scarf.html" rel="alternate" type="text/html" title="Hidden messages and an optimal ternary scarf"/><published>2024-01-20T18:22:00+00:00</published><updated>2024-01-20T18:22:00+00:00</updated><id>/2024/01/20/hidden-message-ternary-scarf</id><content type="html" xml:base="https://oatzy.github.io/2024/01/20/hidden-message-ternary-scarf.html">&lt;p&gt;A while ago, I found a &lt;a href="https://raffamusadesigns.com/tunisian-crochet-ribbed-scarf-pattern/"&gt;pattern for a tunisian crochet scarf&lt;/a&gt; that I kinda liked. The design was straightforward - just three solid blocks; I picked 1 blue, 1 grey, 1 cream.&lt;/p&gt;&#10;&lt;p&gt;I got maybe 20 rows into it, then got bored. I ended up &lt;a href="https://rowhouseyarn.com/blogs/news/frogging-to-frog-or-not-to-frog"&gt;frogging&lt;/a&gt; it.&lt;/p&gt;&#10;&lt;p&gt;But now I have these three balls of super-soft aran yarn, and what to do with them?&lt;/p&gt;&#10;&lt;p&gt;I wondered if I could make the pattern more interesting by cycling - blue, grey, cream, blue, grey, &amp;hellip; - but that&amp;rsquo;s not much more exciting.&lt;/p&gt;&#10;&lt;p&gt;I had the thought that I could completely randomise the colours - for each row, pick one of the three colours at random (roll a dice, even).&lt;/p&gt;&#10;&lt;p&gt;I like the idea of encoding information in arts and crafts. In my &lt;a href="https://oatzy.github.io/2023/07/30/temperature-blanket.html"&gt;temperature blanket&lt;/a&gt; I encoded temperatures as different colours, and months as white and coloured rings representing binary numbers.&lt;/p&gt;&#10;&lt;p&gt;And here I have 3 colours - a &lt;a href="https://en.wikipedia.org/wiki/Ternary_numeral_system"&gt;base 3 encoding&lt;/a&gt; - and, conveniently, three base-3 bits (trits?) can represent 27 values - enough for all 26 letters, plus a whitespace character.&lt;/p&gt;&#10;&lt;h1 id="a-simple-plan"&gt;A simple plan&lt;/h1&gt;&#10;&lt;p&gt;So suppose we want to make a scarf.&lt;/p&gt;&#10;&lt;p&gt;We have three colours, which we might map as&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-jsx" data-lang="jsx"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;cream&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;blue&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;grey&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The most simple mapping of characters to numbers is to make &lt;code&gt;A=1, B=2, C=3&lt;/code&gt;, etc. saving &lt;code&gt;0&lt;/code&gt; for the whitespace character.&lt;/p&gt;&#10;&lt;p&gt;As mentioned, we&amp;rsquo;re representing 27 characters so we need 3 rows per character.&lt;/p&gt;&#10;&lt;p&gt;If we take my name, &lt;code&gt;CHRIS OATES&lt;/code&gt;, and translate it to ternary as above, we get&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-jsx" data-lang="jsx"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="mi"&gt;010&lt;/span&gt; &lt;span class="mi"&gt;022&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt; &lt;span class="mi"&gt;201&lt;/span&gt; &lt;span class="mi"&gt;000&lt;/span&gt; &lt;span class="mi"&gt;120&lt;/span&gt; &lt;span class="mi"&gt;001&lt;/span&gt; &lt;span class="mi"&gt;202&lt;/span&gt; &lt;span class="mi"&gt;012&lt;/span&gt; &lt;span class="mi"&gt;201&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Or in colours&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="/assets/ternary/basic.jpg" alt="Basic mapping in tunisian crochet"&gt;&lt;/p&gt;&#10;&lt;p&gt;Not too bad. But doesn&amp;rsquo;t it feel a little&amp;hellip; unbalanced?&lt;/p&gt;&#10;&lt;p&gt;Ignoring the space character (&lt;code&gt;000&lt;/code&gt;) we have 14 cream, 7 blue, and 9 grey.&lt;/p&gt;&#10;&lt;p&gt;Cream (zeroes) are way over-represented.&lt;/p&gt;&#10;&lt;p&gt;Every possible 3 bit value is represented in the simple encoding, so in a random sequence of letters, we would expect all 3 colours to appear with roughly equal frequency&amp;hellip; except, English isn&amp;rsquo;t a random sequence of letters.&lt;/p&gt;&#10;&lt;h1 id="popularity-contest"&gt;Popularity contest&lt;/h1&gt;&#10;&lt;p&gt;Some letters appear in the English language a lot &lt;a href="https://en.wikipedia.org/wiki/Letter_frequency"&gt;more than others&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;So maybe we want to account for this in our encoding to get a more even balance of colours.&lt;/p&gt;&#10;&lt;p&gt;For example, if we assigned &lt;code&gt;E&lt;/code&gt; as &lt;code&gt;222&lt;/code&gt; then &lt;code&gt;2&lt;/code&gt; would end up very much over represented. It would be better to assign &lt;code&gt;E&lt;/code&gt; a value with all three bits like &lt;code&gt;012&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;The 3 bit ternary numbers can be split into 4 broad groups&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;6 are one of each digit, e.g. &lt;code&gt;012&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;3 are all the same digit (of which &lt;code&gt;000&lt;/code&gt; is our space)&lt;/li&gt;&#10;&lt;li&gt;6 are two the same, split up, e.g. &lt;code&gt;010&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;12 are two the same together; 6 left e.g. &lt;code&gt;001&lt;/code&gt;, and 6 rights e.g. &lt;code&gt;100&lt;/code&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;So the obvious thing is to assign the 6 one-of-each codes to the six most common letters (E, T, A, S, &amp;hellip;), and likewise the 2 all-the-same codes to the two least common letters (Q, Z)&lt;/p&gt;&#10;&lt;p&gt;The six two-split codes can be assigned to the 7th-12th most common letters, on the basis that colours clumped together are less pleasing.&lt;/p&gt;&#10;&lt;p&gt;How the actual codes within those groups are assigned is largely arbitrary (more on that later).&lt;/p&gt;&#10;&lt;p&gt;Here&amp;rsquo;s one possible encoding &lt;sup id="fnref:1"&gt;&lt;a href="#fn:1" class="footnote-ref" role="doc-noteref"&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;e -&amp;gt; &lt;span class="m"&gt;012&lt;/span&gt; t -&amp;gt; &lt;span class="m"&gt;120&lt;/span&gt; i -&amp;gt; &lt;span class="m"&gt;201&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;a -&amp;gt; &lt;span class="m"&gt;021&lt;/span&gt; n -&amp;gt; &lt;span class="m"&gt;102&lt;/span&gt; m -&amp;gt; &lt;span class="m"&gt;210&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;s -&amp;gt; &lt;span class="m"&gt;010&lt;/span&gt; u -&amp;gt; &lt;span class="m"&gt;121&lt;/span&gt; r -&amp;gt; &lt;span class="m"&gt;202&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;w -&amp;gt; &lt;span class="m"&gt;020&lt;/span&gt; d -&amp;gt; &lt;span class="m"&gt;101&lt;/span&gt; k -&amp;gt; &lt;span class="m"&gt;212&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;g -&amp;gt; &lt;span class="m"&gt;011&lt;/span&gt; o -&amp;gt; &lt;span class="m"&gt;122&lt;/span&gt; h -&amp;gt; &lt;span class="m"&gt;200&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;v -&amp;gt; &lt;span class="m"&gt;022&lt;/span&gt; f -&amp;gt; &lt;span class="m"&gt;100&lt;/span&gt; l -&amp;gt; &lt;span class="m"&gt;211&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;p -&amp;gt; &lt;span class="m"&gt;001&lt;/span&gt; j -&amp;gt; &lt;span class="m"&gt;110&lt;/span&gt; b -&amp;gt; &lt;span class="m"&gt;221&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;x -&amp;gt; &lt;span class="m"&gt;002&lt;/span&gt; c -&amp;gt; &lt;span class="m"&gt;112&lt;/span&gt; y -&amp;gt; &lt;span class="m"&gt;220&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;z -&amp;gt; &lt;span class="m"&gt;111&lt;/span&gt; q -&amp;gt; &lt;span class="m"&gt;222&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And here&amp;rsquo;s my name again, using this encoding&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="m"&gt;112&lt;/span&gt; &lt;span class="m"&gt;200&lt;/span&gt; &lt;span class="m"&gt;202&lt;/span&gt; &lt;span class="m"&gt;201&lt;/span&gt; &lt;span class="m"&gt;010&lt;/span&gt; &lt;span class="m"&gt;000&lt;/span&gt; &lt;span class="m"&gt;122&lt;/span&gt; &lt;span class="m"&gt;021&lt;/span&gt; &lt;span class="m"&gt;120&lt;/span&gt; &lt;span class="m"&gt;012&lt;/span&gt; &lt;span class="m"&gt;010&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and in colour&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="/assets/ternary/frequency.jpg" alt="Frequency mapping in stockinette"&gt;&lt;/p&gt;&#10;&lt;p&gt;Hmm&amp;hellip; this looks even less balanced than before.&lt;/p&gt;&#10;&lt;p&gt;However, this time we have 11 cream, 9 blue, and 10 grey, not counting the space block. Almost perfectly balanced.&lt;/p&gt;&#10;&lt;p&gt;So what&amp;rsquo;s the issue? The problem this time is that colours aren&amp;rsquo;t well distributed. We have lots of repeated digits (10, including the white space block), and the blues are biased towards the right.&lt;/p&gt;&#10;&lt;h1 id="going-wider"&gt;Going wider&lt;/h1&gt;&#10;&lt;p&gt;I said in the previous section that how the codes are assigned to letters within each group is arbitrary.&lt;/p&gt;&#10;&lt;p&gt;We can do better than that.&lt;/p&gt;&#10;&lt;p&gt;Suppose we look at &lt;a href="https://en.wikipedia.org/wiki/Bigram"&gt;pairs of letters&lt;/a&gt; - can we assign codes so as to maintain &amp;rsquo;evenness&amp;rsquo; across pairs? And will that make the encoding more even across whole texts? &lt;sup id="fnref:2"&gt;&lt;a href="#fn:2" class="footnote-ref" role="doc-noteref"&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#10;&lt;p&gt;For example, in the above we assigned &lt;code&gt;Q=222&lt;/code&gt;. Now Q is (almost) always followed by a U, so it would be foolish to assign e.g. &lt;code&gt;U=220&lt;/code&gt; as we would then get a run of five 2s in a row &lt;code&gt;222 220&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;It would be better to give U a code with no 2s, say &lt;code&gt;101&lt;/code&gt; -&amp;gt; &lt;code&gt;222 101&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;We should also take into account the white space character. I want to keep white space pinned as &lt;code&gt;000&lt;/code&gt;, so letters which tend to appear at the end of words should not end with 0s, and letters which tend to appear at the start of words should not start with 0s.&lt;/p&gt;&#10;&lt;p&gt;For example, if we assigned &lt;code&gt;Y=100&lt;/code&gt; and &lt;code&gt;D=001&lt;/code&gt;, we might suddenl&lt;strong&gt;y d&lt;/strong&gt;iscover a run of 7 zeros - &lt;code&gt;100 000 001&lt;/code&gt;&lt;/p&gt;&#10;&lt;h1 id="a-more-perfect-encoding"&gt;A more perfect encoding&lt;/h1&gt;&#10;&lt;p&gt;To figure out the &amp;lsquo;best&amp;rsquo; encoding, we need a way to quantify or &amp;lsquo;score&amp;rsquo; each possible encoding.&lt;/p&gt;&#10;&lt;p&gt;We did this implicitly, above, for the 3 bit codes - i.e. the all-different codes are higher scoring than the all-same codes because they have a higher variety of digits/colours.&lt;/p&gt;&#10;&lt;p&gt;Likewise, the two-same-split codes are higher value than 2-same-together codes because the colours are more spread out.&lt;/p&gt;&#10;&lt;p&gt;We just need to extend that logic to pairs of 3 bit codes (or equivalently, 6 bit codes) and come up with an empirical &amp;lsquo;score&amp;rsquo; function, alike&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-jsx" data-lang="jsx"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nx"&gt;score&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;123&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;213&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nx"&gt;score&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;111&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;111&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;For scoring the &amp;lsquo;spread&amp;rsquo; of digits, we can&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;look at each pair of bits&lt;/li&gt;&#10;&lt;li&gt;add 1 if different, else add 0 if same&lt;/li&gt;&#10;&lt;li&gt;divide by the total number of pairs (5)&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;e.g.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-jsx" data-lang="jsx"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="mi"&gt;220&lt;/span&gt; &lt;span class="mi"&gt;021&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;22&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;00&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;02&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;21&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="mf"&gt;0.6&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;For &amp;lsquo;balance&amp;rsquo; we can use &lt;a href="https://en.wikipedia.org/wiki/Entropy_(information_theory)"&gt;entropy&lt;/a&gt; with a base of 3&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-jsx" data-lang="jsx"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;n0&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;log3&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n0&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;n1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;log3&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;n2&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;log3&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n2&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;where &lt;code&gt;n0&lt;/code&gt; is the number of &lt;code&gt;0&lt;/code&gt; digits, etc. &lt;sup id="fnref:3"&gt;&lt;a href="#fn:3" class="footnote-ref" role="doc-noteref"&gt;3&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#10;&lt;p&gt;For example, in the worst case scenario, where all the digits are the same, we get&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-jsx" data-lang="jsx"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;log3&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;log3&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and in the best case, with two of each digit, we get&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-jsx" data-lang="jsx"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;log3&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;log3&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;So now we can smash (multiply) the balance score together with the spread score to get a combined score for a given pair of codes, e.g.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-jsx" data-lang="jsx"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;121&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;102&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;log3&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;log3&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;log3&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.8&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.921&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.736&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now we have to take into account how those codes are assigned to actual letter pairs. That is, it&amp;rsquo;s better to assign high scoring codes to common pairs (EA) than to uncommon pairs (ZW)&lt;/p&gt;&#10;&lt;p&gt;Similar to how we can calculate the frequency of individual letters in the English language - by counting occurences in a text - we can also calculate the frequency of letter pairs in English.&lt;/p&gt;&#10;&lt;p&gt;We can then use these frequencies as a weighting, by multipling the letter pair frequency by the score of the assigned codes.&lt;/p&gt;&#10;&lt;p&gt;So if we come up with a possible mapping, we can calculate the score for each possible letter pair and take the sum, giving us the total score for that mapping&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-jsx" data-lang="jsx"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="nx"&gt;score&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="nx"&gt;f&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;c_i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;c_j&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;c_i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;c_j&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;]&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;For example, in the &lt;code&gt;A=1&lt;/code&gt; encoding, we would calculate&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-jsx" data-lang="jsx"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="nx"&gt;score&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;f&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;001&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;001&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;f&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;001&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;002&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;f&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;z&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;z&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;222&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;222&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This is our metric for comparing and finding the best encoding.&lt;/p&gt;&#10;&lt;h1 id="the-best-enough"&gt;The best enough&lt;/h1&gt;&#10;&lt;p&gt;What now?&lt;/p&gt;&#10;&lt;p&gt;Here&amp;rsquo;s the tricky part - we have a method of scoring any given encoding, but how do we find the &amp;lsquo;best&amp;rsquo; one?&lt;/p&gt;&#10;&lt;p&gt;The problem is, there are &lt;code&gt;26!&lt;/code&gt; (factorial) possible ways of assigning codes to characters - &lt;code&gt;4 x 10^26&lt;/code&gt; - that&amp;rsquo;s more than something something in the universe! 🤯&lt;/p&gt;&#10;&lt;p&gt;Suffice to say, finding an optimal solution &lt;sup id="fnref:4"&gt;&lt;a href="#fn:4" class="footnote-ref" role="doc-noteref"&gt;4&lt;/a&gt;&lt;/sup&gt; is not viable.&lt;/p&gt;&#10;&lt;p&gt;Instead, we can look at a &lt;a href="https://en.wikipedia.org/wiki/Heuristic_(computer_science)"&gt;heuristic solution&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;The approach that worked the best for me was&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;generate a random starting mapping&lt;/li&gt;&#10;&lt;li&gt;for each character in the mapping, find the swap which produces the best score&lt;/li&gt;&#10;&lt;li&gt;repeat 2 until the score doesn&amp;rsquo;t increase anymore&lt;/li&gt;&#10;&lt;li&gt;repeat 1+2 multiple times and pick the best scoring result&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;You can find my code &lt;a href="https://github.com/oatzy/ternary"&gt;here&lt;/a&gt;. I won&amp;rsquo;t go into detail about the code in this post, as it is already quite long. I have provided code comments.&lt;/p&gt;&#10;&lt;p&gt;For my experiments, I grabbed a copy of &lt;a href="https://www.gutenberg.org/ebooks/84"&gt;Frankenstein off Project Gutenberg&lt;/a&gt; to generate the bigram frequencies. This gives us &lt;code&gt;426_160&lt;/code&gt; letter pairs&lt;/p&gt;&#10;&lt;p&gt;As the baseline, the scores for the mappings we already discussed are&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;code&gt;A=1&lt;/code&gt; -&amp;gt; &lt;code&gt;0.51581&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;letter frequency-based -&amp;gt; &lt;code&gt;0.58679&lt;/code&gt; &lt;sup id="fnref:5"&gt;&lt;a href="#fn:5" class="footnote-ref" role="doc-noteref"&gt;5&lt;/a&gt;&lt;/sup&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;I tried multiple runs and the best score I got was &lt;code&gt;0.66869&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;Here&amp;rsquo;s what that mapping looks like&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;a -&amp;gt; &lt;span class="m"&gt;210&lt;/span&gt; b -&amp;gt; &lt;span class="m"&gt;122&lt;/span&gt; c -&amp;gt; &lt;span class="m"&gt;022&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;d -&amp;gt; &lt;span class="m"&gt;121&lt;/span&gt; e -&amp;gt; &lt;span class="m"&gt;021&lt;/span&gt; f -&amp;gt; &lt;span class="m"&gt;221&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;g -&amp;gt; &lt;span class="m"&gt;011&lt;/span&gt; h -&amp;gt; &lt;span class="m"&gt;012&lt;/span&gt; i -&amp;gt; &lt;span class="m"&gt;101&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;j -&amp;gt; &lt;span class="m"&gt;100&lt;/span&gt; k -&amp;gt; &lt;span class="m"&gt;001&lt;/span&gt; l -&amp;gt; &lt;span class="m"&gt;020&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;m -&amp;gt; &lt;span class="m"&gt;220&lt;/span&gt; n -&amp;gt; &lt;span class="m"&gt;202&lt;/span&gt; o -&amp;gt; &lt;span class="m"&gt;120&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;p -&amp;gt; &lt;span class="m"&gt;110&lt;/span&gt; q -&amp;gt; &lt;span class="m"&gt;222&lt;/span&gt; r -&amp;gt; &lt;span class="m"&gt;201&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;s -&amp;gt; &lt;span class="m"&gt;212&lt;/span&gt; t -&amp;gt; &lt;span class="m"&gt;102&lt;/span&gt; u -&amp;gt; &lt;span class="m"&gt;010&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;v -&amp;gt; &lt;span class="m"&gt;002&lt;/span&gt; w -&amp;gt; &lt;span class="m"&gt;211&lt;/span&gt; x -&amp;gt; &lt;span class="m"&gt;200&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;y -&amp;gt; &lt;span class="m"&gt;112&lt;/span&gt; z -&amp;gt; &lt;span class="m"&gt;111&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I tried running it a few times, and it consistently turned up this mapping as the best, which suggests it&amp;rsquo;s the most optimal. Or perhaps it&amp;rsquo;s the most optimal solution that this method can generate; maybe a different optimisation method could generate an even better solution. &lt;sup id="fnref:6"&gt;&lt;a href="#fn:6" class="footnote-ref" role="doc-noteref"&gt;6&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#10;&lt;p&gt;Here&amp;rsquo;s what my name looks like with the optimised mapping&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="m"&gt;022&lt;/span&gt; &lt;span class="m"&gt;012&lt;/span&gt; &lt;span class="m"&gt;201&lt;/span&gt; &lt;span class="m"&gt;101&lt;/span&gt; &lt;span class="m"&gt;212&lt;/span&gt; &lt;span class="m"&gt;000&lt;/span&gt; &lt;span class="m"&gt;120&lt;/span&gt; &lt;span class="m"&gt;210&lt;/span&gt; &lt;span class="m"&gt;102&lt;/span&gt; &lt;span class="m"&gt;021&lt;/span&gt; &lt;span class="m"&gt;212&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and here it is in colours&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="/assets/ternary/optimal.jpg" alt="Optimal mapping in half-treble crochet"&gt;&lt;/p&gt;&#10;&lt;p&gt;Doesn&amp;rsquo;t that look so much more balanced?&lt;/p&gt;&#10;&lt;p&gt;Here we have 11 cream, 10 blue, and 12 grey, this time including the space block since it was part of the optimisation. It&amp;rsquo;s almost perfectly balanced, and this time it also has a much better spread of colours; we have only 5 repeated digits (of which 2 are in the space block)&lt;/p&gt;&#10;&lt;h1 id="spinning-out"&gt;Spinning out&lt;/h1&gt;&#10;&lt;p&gt;This idea can be extended to different bases. For example, with 4 colours and 2 rows per colour you get 64 possibilities - enough for upper and lower case, 10 digits, 1 space, and 1 left over for a period (or exclamation mark!)&lt;/p&gt;&#10;&lt;p&gt;The principle remains the same, you just have more character combinations to deal with.&lt;/p&gt;&#10;&lt;p&gt;Similarly, I&amp;rsquo;ve been talking about a scarf, but this would work just as well for a blanket. For, what is a blanket if not a really wide scarf?&lt;/p&gt;&#10;&lt;p&gt;Alternatively, we could construct a blanket of squares - similar to my temperature blanket - with one block per character comprised of 3 bands of colour representing the 3 bits.&lt;/p&gt;&#10;&lt;p&gt;This can make for a much more striking design&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="/assets/ternary/squares.jpg" alt="Example basic mapping in squares design"&gt;&lt;/p&gt;&#10;&lt;p&gt;Tho in the squares case, the criteria for what is optimal is slightly different.&lt;/p&gt;&#10;&lt;p&gt;For example, in the above the second and third to last squares are &lt;code&gt;202 012&lt;/code&gt; which has no repeated digits&lt;/p&gt;&#10;&lt;p&gt;But with squares&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="m"&gt;22222&lt;/span&gt; &lt;span class="m"&gt;22222&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="m"&gt;20002&lt;/span&gt; &lt;span class="m"&gt;21112&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="m"&gt;20202&lt;/span&gt; &lt;span class="m"&gt;21012&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="m"&gt;20002&lt;/span&gt; &lt;span class="m"&gt;21112&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="m"&gt;22222&lt;/span&gt; &lt;span class="m"&gt;22222&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;the last digits &lt;sup id="fnref:7"&gt;&lt;a href="#fn:7" class="footnote-ref" role="doc-noteref"&gt;7&lt;/a&gt;&lt;/sup&gt; - the outer rings of 2s - &lt;strong&gt;are&lt;/strong&gt; adjacent.&lt;/p&gt;&#10;&lt;p&gt;And that&amp;rsquo;s only thinking one-dimensionally. For a blanket, we&amp;rsquo;re going to have a grid, with the text split across multiple rows. How do we account for that?&lt;/p&gt;&#10;&lt;p&gt;And notice that in a square the outer ring would use a lot more yarn than the inner ring. So maybe we&amp;rsquo;d like to ensure that each digit is represented in each position roughly equally - that we use roughly equal amounts of each colour.&lt;/p&gt;&#10;&lt;p&gt;Maybe I&amp;rsquo;ll come back to this idea in a future blog&amp;hellip;&lt;/p&gt;&#10;&lt;h1 id="unravelled"&gt;Unravelled&lt;/h1&gt;&#10;&lt;p&gt;At this point, you&amp;rsquo;re expecting to see a completed scarf?&lt;/p&gt;&#10;&lt;p&gt;The truth is, I already used some of the yarn I mentioned to &lt;a href="https://www.ravelry.com/projects/oatzy/crochet-slipper-socks"&gt;make a sock&lt;/a&gt;. Yes, just the one sock. And maybe someday I&amp;rsquo;ll get around to making it a matching pair.&lt;/p&gt;&#10;&lt;p&gt;And maybe someday I&amp;rsquo;ll even make a ternary scarf.&lt;/p&gt;&#10;&lt;p&gt;But first I need to figure out what message is worth wearing around one&amp;rsquo;s neck&amp;hellip;&lt;/p&gt;&#10;&lt;p&gt;Chris.&lt;/p&gt;&#10;&lt;p&gt;[was this all just a waste of time? you must be new here]&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;h1 id="epilogue-structure-and-interpretation-of-scarf"&gt;Epilogue: Structure and interpretation of scarf&lt;/h1&gt;&#10;&lt;p&gt;Suppose you&amp;rsquo;re presented with a scarf. It&amp;rsquo;s made up of stripes of three different colours, but the patterns seem&amp;hellip; odd. Random? But why would anyone make a random patterned scarf?&lt;/p&gt;&#10;&lt;p&gt;Given that there are three colours, you think maybe it&amp;rsquo;s a base 3 encoding, and you intuit that 3 rows gives you 27 sequences - enough for 26 letters and a space.&lt;/p&gt;&#10;&lt;p&gt;You might assume a basic encoding - &lt;code&gt;A=1&lt;/code&gt;, &lt;code&gt;B=2&lt;/code&gt;, etc. But you don&amp;rsquo;t know how the colours map to bits &lt;code&gt;0&lt;/code&gt;, &lt;code&gt;1&lt;/code&gt;, &lt;code&gt;2&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;But then, there are only 6 possible arrangements, so you can just try them all, and see what yields a meaningful message. Perhaps you notice a particular colour regularly appears in blocks of 3, and you think &amp;ldquo;maybe that&amp;rsquo;s a space character&amp;rdquo;. You call that colour &lt;code&gt;0&lt;/code&gt; and now you only need to figure out which colour is &lt;code&gt;1&lt;/code&gt; and which is &lt;code&gt;2&lt;/code&gt; - two possibilities.&lt;/p&gt;&#10;&lt;p&gt;It&amp;rsquo;s not trivial, but it&amp;rsquo;s possible. This feels ideal to me.&lt;/p&gt;&#10;&lt;p&gt;By comparison, you couldn&amp;rsquo;t infer the frequency-based or optimal encoding in the same way - in the first one, some of the assignments are arbitrary, and in the second the assignment is heuristic so even following the same procedure you might not reproduce the same mapping.&lt;/p&gt;&#10;&lt;p&gt;If the message (scarf) is long enough, you can ignore the base 3 aspect, treat each 3-row sequence as an arbitrary symbol and perform &lt;a href="https://en.wikipedia.org/wiki/Frequency_analysis"&gt;frequency analysis&lt;/a&gt; to figure out the letter mapping.&lt;/p&gt;&#10;&lt;p&gt;But we&amp;rsquo;re talking a &lt;a href="https://en.wikipedia.org/wiki/Fourth_Doctor#/media/File:The_Fourth_Doctor_(6097263309).jpg"&gt;Tom Baker length of scarf&lt;/a&gt;, at least.&lt;/p&gt;&#10;&lt;h1 id="appendix-the-example-stitches"&gt;Appendix: the example stitches&lt;/h1&gt;&#10;&lt;p&gt;Each of the examples uses a different stitch/technique. Some may call this an unfair comparison, but it made things more interesting for me ;)&lt;/p&gt;&#10;&lt;p&gt;The first example, for the &lt;code&gt;A=1&lt;/code&gt; encoding, was done in &lt;a href="https://en.wikipedia.org/wiki/Tunisian_crochet"&gt;tunisian crochet&lt;/a&gt;, using repeated tunisian simple stitch (TSS)&lt;/p&gt;&#10;&lt;p&gt;The second example, for the frequency encoding, was knitted in a basic &lt;a href="https://en.wikipedia.org/wiki/Basic_knitted_fabrics#Stockinette/stocking_stitch_and_reverse_stockinette_stitch"&gt;stockinette&lt;/a&gt; - 1 row knit stitch + 1 row purl stitch.&lt;/p&gt;&#10;&lt;p&gt;In this case there are actually two rows per bit (1 knit + 1 purl). This was mostly so the colour change would always happened along the same edge, for my convenience.&lt;/p&gt;&#10;&lt;p&gt;The last example, for the optimal encoding, was done in regular crochet, using repeated half-treble (Htr) crochet stitches in UK notation, or half-double (Hdc) in US notation.&lt;/p&gt;&#10;&lt;p&gt;I didn&amp;rsquo;t do an example for the squares because that would have required cutting the yarn (and also I&amp;rsquo;m lazy).&lt;/p&gt;&#10;&lt;h1 id="footnotes"&gt;Footnotes&lt;/h1&gt;&#10;&lt;div class="footnotes" role="doc-endnotes"&gt;&#10;&lt;hr&gt;&#10;&lt;ol&gt;&#10;&lt;li id="fn:1"&gt;&#10;&lt;p&gt;For the common-ness of letters I &lt;a href="https://en.wikipedia.org/wiki/Morse_code#Alternative_display_of_common_characters_in_International_Morse_code"&gt;copied Morse code&lt;/a&gt;, which isn&amp;rsquo;t strictly accurate to the English language. Tho it should be said that any frequency mapping is not going to be universally correct. It depends on the text it&amp;rsquo;s calculated from. Tho they do tend to align at the extremes.&amp;#160;&lt;a href="#fnref:1" class="footnote-backref" role="doc-backlink"&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li id="fn:2"&gt;&#10;&lt;p&gt;Naturally we can extend this to groups of 3 letters, groups of N letters, or whole words. But let&amp;rsquo;s not get carried away ;)&amp;#160;&lt;a href="#fnref:2" class="footnote-backref" role="doc-backlink"&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li id="fn:3"&gt;&#10;&lt;p&gt;Fun fact, even tho there are &lt;code&gt;27 * 27 = 729&lt;/code&gt; possible pairs of 3 digit codes, if we ignore permutations, there are only 7 unique partitions of 6 digits into 3 types, and therefore only 7 entropies to calculate&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-jsx" data-lang="jsx"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="mi"&gt;600&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="mi"&gt;510&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="mf"&gt;0.410&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="mi"&gt;420&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="mf"&gt;0.579&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="mi"&gt;411&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="mf"&gt;0.790&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="mi"&gt;330&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="mf"&gt;0.631&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="mi"&gt;321&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="mf"&gt;0.921&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="mi"&gt;222&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&amp;#160;&lt;a href="#fnref:3" class="footnote-backref" role="doc-backlink"&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/li&gt;&#10;&lt;li id="fn:4"&gt;&#10;&lt;p&gt;there are at least two optimal solutions; for any given solution, we can swap the 1s with the 2s and get another mapping with the exact same score. We can&amp;rsquo;t do the same with 0s since we pinned the white space character as &lt;code&gt;000&lt;/code&gt;, otherwise there would be 6 equivalents for each solution.&amp;#160;&lt;a href="#fnref:4" class="footnote-backref" role="doc-backlink"&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li id="fn:5"&gt;&#10;&lt;p&gt;as mentioned in footnote 1, the frequency encoding in this blog is based on Morse code. An encoding based on measured letter frequencies scores &lt;code&gt;0.62144&lt;/code&gt;; better than Morse, but still less than &amp;lsquo;optimal&amp;rsquo;&amp;#160;&lt;a href="#fnref:5" class="footnote-backref" role="doc-backlink"&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li id="fn:6"&gt;&#10;&lt;p&gt;This mapping was a close second&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;a -&amp;gt; &lt;span class="m"&gt;120&lt;/span&gt; b -&amp;gt; &lt;span class="m"&gt;211&lt;/span&gt; c -&amp;gt; &lt;span class="m"&gt;011&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;d -&amp;gt; &lt;span class="m"&gt;212&lt;/span&gt; e -&amp;gt; &lt;span class="m"&gt;012&lt;/span&gt; f -&amp;gt; &lt;span class="m"&gt;112&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;g -&amp;gt; &lt;span class="m"&gt;022&lt;/span&gt; h -&amp;gt; &lt;span class="m"&gt;021&lt;/span&gt; i -&amp;gt; &lt;span class="m"&gt;202&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;j -&amp;gt; &lt;span class="m"&gt;200&lt;/span&gt; k -&amp;gt; &lt;span class="m"&gt;002&lt;/span&gt; l -&amp;gt; &lt;span class="m"&gt;010&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;m -&amp;gt; &lt;span class="m"&gt;110&lt;/span&gt; n -&amp;gt; &lt;span class="m"&gt;101&lt;/span&gt; o -&amp;gt; &lt;span class="m"&gt;210&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;p -&amp;gt; &lt;span class="m"&gt;220&lt;/span&gt; q -&amp;gt; &lt;span class="m"&gt;111&lt;/span&gt; r -&amp;gt; &lt;span class="m"&gt;102&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;s -&amp;gt; &lt;span class="m"&gt;121&lt;/span&gt; t -&amp;gt; &lt;span class="m"&gt;201&lt;/span&gt; u -&amp;gt; &lt;span class="m"&gt;020&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;v -&amp;gt; &lt;span class="m"&gt;001&lt;/span&gt; w -&amp;gt; &lt;span class="m"&gt;122&lt;/span&gt; x -&amp;gt; &lt;span class="m"&gt;100&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;y -&amp;gt; &lt;span class="m"&gt;221&lt;/span&gt; z -&amp;gt; &lt;span class="m"&gt;222&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Its score is &lt;code&gt;4 x 10^-16&lt;/code&gt; less than the &amp;lsquo;optimal&amp;rsquo;. But notice, if you swap all the 1s for 2s and vice versa in the optimal mapping you get this mapping! This is actually expected, per footnote 4. The difference in scores is probably a floating point rounding quirk.&amp;#160;&lt;a href="#fnref:6" class="footnote-backref" role="doc-backlink"&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li id="fn:7"&gt;&#10;&lt;p&gt;I think you would call that.. little-endian? I could never remember which is which&amp;#160;&lt;a href="#fnref:7" class="footnote-backref" role="doc-backlink"&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;/div&gt;&#10;</content><author><name>Chris Oates</name></author><category term="crochet"/><category term="maths"/><category term="optimisation"/><category term="coding"/><summary type="html">&lt;p&gt;A while ago, I found a &lt;a href="https://raffamusadesigns.com/tunisian-crochet-ribbed-scarf-pattern/"&gt;pattern for a tunisian crochet scarf&lt;/a&gt; that I kinda liked. The design was straightforward - just three solid blocks; I picked 1 blue, 1 grey, 1 cream.&lt;/p&gt;&#10;&lt;p&gt;I got maybe 20 rows into it, then got bored. I ended up &lt;a href="https://rowhouseyarn.com/blogs/news/frogging-to-frog-or-not-to-frog"&gt;frogging&lt;/a&gt; it.&lt;/p&gt;&#10;&lt;p&gt;But now I have these three balls of super-soft aran yarn, and what to do with them?&lt;/p&gt;&#10;&lt;p&gt;I wondered if I could make the pattern more interesting by cycling - blue, grey, cream, blue, grey, &amp;hellip; - but that&amp;rsquo;s not much more exciting.&lt;/p&gt;</summary></entry><entry><title type="html">Temperature Blanket - Completed</title><link href="https://oatzy.github.io/2024/01/10/temperature-blanket-completed.html" rel="alternate" type="text/html" title="Temperature Blanket - Completed"/><published>2024-01-10T18:14:00+00:00</published><updated>2024-01-10T18:14:00+00:00</updated><id>/2024/01/10/temperature-blanket-completed</id><content type="html" xml:base="https://oatzy.github.io/2024/01/10/temperature-blanket-completed.html">&lt;p&gt;A temperature blanket is a crochet or knitting project where one makes a blanket over the course of a year, doing a piece a day with the colours based on each day&amp;rsquo;s temperature.&lt;/p&gt;&#10;&lt;p&gt;For the full background and design of my blanket, see the &lt;a href="https://oatzy.github.io/2023/07/30/temperature-blanket.html"&gt;previous blog post&lt;/a&gt;&lt;/p&gt;&#10;&lt;h1 id="god-laughs"&gt;God laughs&lt;/h1&gt;&#10;&lt;p&gt;When we last left our temperature blanket, it was the end of July, and I said&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;we haven&amp;rsquo;t made it into the oranges/reds [&amp;hellip;] it would be nice to see those colours incorporated&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&lt;p&gt;Turns out I got my wish, but when I least expected it.&lt;/p&gt;&#10;&lt;p&gt;Going back to the original layout&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="/assets/blanket_complete/old-layout.png" alt="The old layout"&gt;&lt;/p&gt;&#10;&lt;p&gt;the plan was that when I got to the start of September, I would move to the top right, following a truncated z-ordered curve.&lt;/p&gt;&#10;&lt;p&gt;But then, come the start of September, we had an unexpected heatwave - including the hottest day of the year! (22.2C)&lt;/p&gt;&#10;&lt;p&gt;Following the original plan would have put these yellows and oranges next to the blues of March/April, which felt to me like it wouldn&amp;rsquo;t look so good.&lt;/p&gt;&#10;&lt;h1 id="back-to-the-old-drawing-board"&gt;Back to the old drawing board&lt;/h1&gt;&#10;&lt;p&gt;The most obvious redesign - instead of shifting to top right, we simply continue downward, but otherwise adhering to the z-order layout.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="/assets/blanket_complete/new-layout.png" alt="The new layout"&gt;&lt;/p&gt;&#10;&lt;p&gt;In retrospect, this feels much more natural.&lt;/p&gt;&#10;&lt;p&gt;Doing this, the completed blanket becomes 16x24 squares. This is slightly longer and thinner than the original design, and comes out to 384 squares total.&lt;/p&gt;&#10;&lt;p&gt;The original plan had 365 day + 12 months = 377 with 1 spare to represent the year (378 total). In the new plan, I was left with 7 spare squares.&lt;/p&gt;&#10;&lt;p&gt;7 is a bit of an &amp;lsquo;odd&amp;rsquo; number, so I decided to use one to &amp;lsquo;sign&amp;rsquo; the piece, and then use the other 6 as a block for representing the year as a whole.&lt;/p&gt;&#10;&lt;p&gt;The signature square is straightforward - it&amp;rsquo;s my initials, CO. I chose a shade of grey so that it would be cohesive with the overall design, without standing out or being mistaken for any of the other colours used.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="/assets/blanket_complete/signature-square.jpg" alt="Completed blanket"&gt;&lt;/p&gt;&#10;&lt;p&gt;The year marker is more interesting. The original thought was to represent the year &amp;lsquo;2023&amp;rsquo; in a similar way to the month markers, which are the month numbers in binary.&lt;/p&gt;&#10;&lt;p&gt;I hit on the fact that 2023 in hexadecimal is &lt;code&gt;7e7&lt;/code&gt; which is conveniently 3 digits (and I have 6 squares to fill). It&amp;rsquo;s also a palindrome, which makes for a nice, symmetrical pattern.&lt;/p&gt;&#10;&lt;p&gt;Each square represents 2 bits - an outer ring and the centre, plus a separating ring which is always white. And each vertical pair together represent one hex digit (nibble?)&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="/assets/blanket_complete/year-block.jpg" alt="Completed blanket"&gt;&lt;/p&gt;&#10;&lt;p&gt;The bits are read outside-in - so for example, top left is white outer and solid centre = &lt;code&gt;01&lt;/code&gt;, bottom left is solid outer and centre = &lt;code&gt;11&lt;/code&gt;; so all together the pair is &lt;code&gt;0111&lt;/code&gt; or 7 in hex.&lt;/p&gt;&#10;&lt;p&gt;The complete pattern also looks &lt;a href="https://en.wikipedia.org/wiki/Pareidolia"&gt;kind of like&lt;/a&gt; a smiley face ° □ °&lt;/p&gt;&#10;&lt;p&gt;Naturally, the colour represents the average temperature across the whole year (9.9C).&lt;/p&gt;&#10;&lt;p&gt;I also broke the z-ordering a little - the December marker (binary of 12) looks too similar to the &lt;code&gt;10&lt;/code&gt; year square, so I wanted to move it away from the year block so as not to confuse the design.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="/assets/blanket_complete/december-layout.png" alt="December layout"&gt;&lt;/p&gt;&#10;&lt;p&gt;(If I&amp;rsquo;d thought of it sooner, I would have put the signature as the bottom-left square of the complete blanket, in the October region)&lt;/p&gt;&#10;&lt;h1 id="wrapped-up"&gt;Wrapped up&lt;/h1&gt;&#10;&lt;p&gt;Without further rambling, here&amp;rsquo;s the completed blanket&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="/assets/blanket_complete/completed-blanket.jpg" alt="Completed blanket"&gt;&lt;/p&gt;&#10;&lt;p&gt;(rotated 90 degrees, January at top right)&lt;/p&gt;&#10;&lt;p&gt;The completed blanket is ~118x170cm&lt;/p&gt;&#10;&lt;p&gt;Overall, it wasn&amp;rsquo;t too difficult on a technical level, but boy did it take a lot of time. Including joining and weaving in ends it took ~ 25mins per square, which comes out at ~157 hours (!) total, or ~3 hours a week.&lt;/p&gt;&#10;&lt;p&gt;As for the scarf I mentioned in the previous post; well&amp;hellip; the blanket alone was a &lt;em&gt;lot&lt;/em&gt; of effort. And I couldn&amp;rsquo;t muster the enthusiasm to keep working on it. Two year-long projects at once was a little ambitious, oh well.&lt;/p&gt;&#10;&lt;p&gt;Chris.&lt;/p&gt;&#10;&lt;p&gt;[Now I&amp;rsquo;ve got to figure out what to do with the damn thing&amp;hellip;]&lt;/p&gt;&#10;</content><author><name>Chris Oates</name></author><category term="crochet"/><category term="maths"/><category term="infographic"/><summary type="html">&lt;p&gt;A temperature blanket is a crochet or knitting project where one makes a blanket over the course of a year, doing a piece a day with the colours based on each day&amp;rsquo;s temperature.&lt;/p&gt;&#10;&lt;p&gt;For the full background and design of my blanket, see the &lt;a href="https://oatzy.github.io/2023/07/30/temperature-blanket.html"&gt;previous blog post&lt;/a&gt;&lt;/p&gt;&#10;&lt;h1 id="god-laughs"&gt;God laughs&lt;/h1&gt;&#10;&lt;p&gt;When we last left our temperature blanket, it was the end of July, and I said&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;we haven&amp;rsquo;t made it into the oranges/reds [&amp;hellip;] it would be nice to see those colours incorporated&lt;/p&gt;&#10;&lt;/blockquote&gt;</summary></entry></feed>