Two algebraic delights
Finding a correspondence between mathematical objects and algebraic expressions.
open full screen ↗ Your browser can't display this PDF inline. Open it directly.
File servers
Since the last Haskell cicada: Electromagnet Pulse was so much fun, let’s do another one from the same chapter from “Algorithm Design” by Jon Kleinberg and Éva Tardos.
Algorithm Design by Jon Kleinberg, Éva Tardos "Algorithm Design takes a fresh approach to the algorithms course, introducing algorithmic ideas through the real-world problems that motivate them. In a clear, direct style, Jon Kleinberg and Eva Tardos teach students to analyze and define problems for themselves, and from this to recognize which ... The exercise is Exercise 12 on page 323:
Electromagnetic Pulse
This Haskell cicada came about because sometimes, when I’m bored, I pick a random exercise from a random book and try to solve it. In this case the book was “Algorithm Design” by Jon Kleinberg and Éva Tardos.
Algorithm Design by Jon Kleinberg, Éva Tardos "Algorithm Design takes a fresh approach to the algorithms course, introducing algorithmic ideas through the real-world problems that motivate them. In a clear, direct style, Jon Kleinberg and Eva Tardos teach students to analyze and define problems for themselves, and from this to recognize which ... The exercise I randomly picked from the book is Exercise 8 on page 319:
LaTeX setup
Intro # As I mentioned in the Intro of the Haskell setup post, tooling changes often and becomes outdated quickly. So why write this post at all? Honestly, it is mostly for me, like much of this blog I don’t think I have (m)any readers 🙂. . My math notes are infrequent enough (my last one was six months ago) that I run the risk of forgetting the details of this Rube Goldberg machine of a workflow and then I won’t be able to maintain or fix it.
Haskell setup revisited
I said in Haskell setup that posts like these don’t age well. And sure enough, here I am with a revision. After dipping my toes in the Haskell testing waters I wanted a project scaffolding that is different from what cabal init generates:
I wanted a proper testing setup that allows me to also test module internals. I also wanted to solve having saved snippets of bindings loaded into the repl so I don’t have to repeatedly type the same expressions. After a bunch of trials and errors I settled on the project structure as seen in magicsquare. It breaks out internals into a separate module so it can be tested. It defines an Examples module that imports the other two modules and defines snippets useful in the repl. I invoke the repl like so:
Haskell setup
Intro # Posts like this one don’t age well. Tooling changes all the time. And the other thing is: I do Haskell just for fun, ie silly little exercises with only pure functions. So take this setup with a grain of salt. And if you stumbled on this from the future, there’s probably better options for you.
With these disclaimers out of the way, let’s see the setup.
Connected Magic Squares (Part 5)
Imagine a 6 by 6 grid of squares, that can either be black or white. It has to fulfill the following properties: 1. Each row and column needs to have 3 white and 3 black squares. 2. All black squares have to be orthogonally connected. Prove that such a grid cannot exist. part 1: naive brute force exhaustive search part 2: smarter exhaustive search part 3: inductive graphs part 4: connected magic squares part 5: experiments Note: in our digital representation black squares are ones and white squares are zeros.
Connected Magic Squares (Part 4)
Imagine a 6 by 6 grid of squares, that can either be black or white. It has to fulfill the following properties: 1. Each row and column needs to have 3 white and 3 black squares. 2. All black squares have to be orthogonally connected. Prove that such a grid cannot exist. part 1: naive brute force exhaustive search part 2: smarter exhaustive search part 3: inductive graphs part 4: connected magic squares part 5: experiments Note: in our digital representation black squares are ones and white squares are zeros.
Connected Magic Squares (Part 3)
Imagine a 6 by 6 grid of squares, that can either be black or white. It has to fulfill the following properties: 1. Each row and column needs to have 3 white and 3 black squares. 2. All black squares have to be orthogonally connected. Prove that such a grid cannot exist. part 1: naive brute force exhaustive search part 2: smarter exhaustive search part 3: inductive graphs part 4: connected magic squares part 5: experiments Note: in our digital representation black squares are ones and white squares are zeros.
Connected Magic Squares (Part 2)
Imagine a 6 by 6 grid of squares, that can either be black or white. It has to fulfill the following properties: 1. Each row and column needs to have 3 white and 3 black squares. 2. All black squares have to be orthogonally connected. Prove that such a grid cannot exist. part 1: naive brute force exhaustive search part 2: smarter exhaustive search part 3: inductive graphs part 4: connected magic squares part 5: experiments Note: in our digital representation black squares are ones and white squares are zeros.
Connected Magic Squares (Part 1)
part 1: naive brute force exhaustive search part 2: smarter exhaustive search part 3: inductive graphs part 4: connected magic squares part 5: experiments I found this problem on one of my Mastodon feeds:
Imagine a 6 by 6 grid of squares, that can either be black or white. It has to fulfill the following properties: 1. Each row and column needs to have 3 white and 3 black squares. 2. All black squares have to be orthogonally connected. Prove that such a grid cannot exist. Note: in our digital representation black squares are ones and white squares are zeros.
Deadloch
I recently needed a distraction for a ten-hour flight. I cannot sleep on flights and I’m also too uncomfortable to do any real work or read. So it has to be binging a show. I chose Deadloch, a murder mystery show with eight one hour episodes, making it the ideal length for a ten hour flight assuming it is compelling enough to stick around.
Transcription
Transcription by Kate Atkinson A dramatic story of WWII espionage, betrayal, and loyalty, by the #1 bestselling author of Life After Life In 1940, eighteen-year old Juliet Armstrong is reluctantly recruited into the world of espionage. Sent to an obscure department of MI5 tasked with monitoring the comings and goings of British ... Kate Atkinson’s novel Transcription is the answer to the question of what happens if you take the wicked humor of Martin Amis, John Le Carre prose elegance and the emotional honesty of Iris Murdoch and blend them all together.
Keyoxide
Introduction # People are familiar by now with the Mastodon account verification system: if you want to prove that you own both a particular Mastodon account and a particular website By owning I mean you hold the login credentials. , you add a link with the rel="me" attribute to your website pointing back to your Mastodon profile and in the Mastodon profile you add a link to your website page that contains that rel="me" anchor. The Mastodon instance will fetch that page, find the rel="me" anchor and reward you with a green checkmark next to your website link in your Mastodon profile. This is very simple and straightforward but it does imply a certain level of trust in the Mastodon instance doing the verification.
Mastosync
Introduction # One of the cool things about Mastodon, Notion and RSS is great API availability and nice Go libraries covering these APIs:
Jomei Notion Mattn Mastodon MMCDole RSS Feeds Pretty early after migrating to Mastodon, I started thinking about a little project that would use these APIs: a tool that automatically toots links to new blog posts appearing in an RSS feed. Obviously as with most things something like this already exists: mastofeed. But I wanted to put my own spin on it and play with the APIs. One afternoon of hacking later and I had mastosync.
Nova and Hugo
When the Nova 11 announcement appeared in one of my feeds, it was clear I wouldn’t be able to resist. I love, love, love truly polished native Mac apps and Nova completely nails it in that category. I played with previous versions of Nova before but I never had a real use case for it. I’m not a web developer and adapting it to the programming environments I use is somewhat challenging so I always slide back to specialized IDEs for those (Goland for Go, CLion for C++, Visual Studio Code for Haskell and TeXShop for LaTeX). But now I have this blog and this is all Markdown, CSS, Html, Javascript, in other words a great use case for Nova.
Burnside Polya counting
Counting number of ways to color some objects under the action of a group.
open full screen ↗ Your browser can't display this PDF inline. Open it directly.
Safety in Numbers
This Haskell cicada was a Google Codejam competition problem way back in 2012 Codejam Round 1B 2012: Safety in Numbers. No, I did not participate. I’m not very good and I’m also not very fast, two things needed in coding competitions. I do like these competitions as a source of problems to tackle. .
Problem # There are $n$ contestants in a reality TV show. Each contestant is assigned a point value by the judges and receives votes from the audience. The point value given by the judges and the audience’s votes are combined to form a final score for the contestant, in the following way:
Majority
This Haskell cicada is another small problem from long time ago.
Given a set of marbles of different colors, find the majority color knowing it exists.
Let $M$ be the set of marbles and $|M| = n$. We know that there is a color $c$ such that
$$ |\{ m \in M: color(m) = c \}| > \frac{n}{2} $$
We prove the following lemma:
Given $x, y \in M$ with $color(x) \neq color(y)$, then the majority color in $M$ is also the majority color in $M \setminus \{x, y\}$.
Celebs
For this Haskell cicada I’m dusting off a small problem that I used long time ago to practice Scala:
Given is a list of people at a party and for each person the list of people they know at the party. We want to find the celebrities at the party. A celebrity is a person that everybody at the party knows but that only knows other celebrities. At least one celebrity is present at the party.