Import Quarto posts and expand blog sync bridge
Some checks failed
Build / build (push) Has been cancelled

This commit is contained in:
Neeldhara Misra 2026-06-20 04:01:13 +01:00
parent 4ddaba7c7d
commit e7227844c7
406 changed files with 7943 additions and 7637 deletions

View file

@ -16,8 +16,47 @@ const BlogPosts = ({
// Get the first post as the featured post
const featuredPost = posts[0];
const remainingPosts = posts.slice(1);
const slugFor = (post: any) => post.id.replace(/\/index$/, "");
const hrefFor = (post: any) =>
collection ? `/${collection}/${post.id}/` : `/${post.id}/`;
collection ? `/${collection}/${slugFor(post)}/` : `/${slugFor(post)}/`;
const PostVisual = ({
post,
featured = false,
}: {
post: any;
featured?: boolean;
}) => {
if (post.data.image) {
return (
<img
src={post.data.image}
alt={post.data.title}
className="aspect-video w-full rounded-lg object-cover transition-transform group-hover:scale-[1.02]"
/>
);
}
return (
<div className="bg-accent/70 text-accent-foreground flex aspect-video w-full items-center justify-center rounded-lg border px-6 text-center">
<span
className={
featured ? "font-fraunces text-2xl" : "font-fraunces text-lg"
}
>
{post.data.title}
</span>
</div>
);
};
if (!featuredPost) {
return (
<div className="text-muted-foreground container max-w-3xl py-16">
No posts yet.
</div>
);
}
return (
<div className="relative py-10 md:py-16 lg:py-20">
@ -35,11 +74,7 @@ const BlogPosts = ({
<div className="flex flex-col gap-6 lg:flex-row">
<div className="lg:w-1/2">
<div className="p-2 lg:p-4">
<img
src={featuredPost.data.image}
alt={featuredPost.data.title}
className="aspect-video w-full rounded-lg object-cover transition-transform group-hover:scale-[1.02]"
/>
<PostVisual post={featuredPost} featured />
</div>
</div>
<div className="flex flex-col justify-center p-4 pb-8 lg:w-1/2 lg:pr-8">
@ -89,11 +124,7 @@ const BlogPosts = ({
href={hrefFor(post)}
>
<div className="p-2">
<img
src={post.data.image}
alt={post.data.title}
className="aspect-video w-full rounded-lg object-cover transition-transform group-hover:scale-[1.01]"
/>
<PostVisual post={post} />
</div>
<div className="px-4 pb-5 pt-2">
<h2 className="mb-2 text-xl font-semibold group-hover:underline">

View file

@ -1,40 +0,0 @@
---
title: "Algorithmic Sketches: Visualizing Data Structures"
description: "Hand-drawn illustrations of algorithms and data structures - making the abstract tangible."
pubDate: "Jan 25 2024"
image: "https://images.unsplash.com/photo-1581337204873-ef36aa186caa?w=400&auto=format&fit=crop&q=60"
authorImage: "/avatar/avatar1.png"
authorName: "Neeldhara"
---
# Algorithmic Sketches: Visualizing Data Structures
Sometimes the best way to understand an algorithm is to draw it.
## Today's Sketch: Red-Black Trees
![Red-Black Tree Rotation](sketch-placeholder)
The rotation operation finally clicked when I drew it step-by-step. Each node's journey through the rotation becomes a story.
## The Process
1. Start with pencil - mistakes are part of learning
2. Trace the algorithm's execution
3. Add color to highlight invariants
4. Annotate with key insights
## Why Drawing Helps
- Forces you to slow down and really see the structure
- Reveals patterns that code obscures
- Creates memorable mental models
- Makes teaching more engaging
## This Week's Challenge
Draw your own version of quicksort partitioning. Share it and let's learn from each other's visualizations.
## The Art in Computer Science
Algorithms are beautiful. Drawing them reminds us that computer science is as much art as it is science.

View file

@ -1,41 +0,0 @@
---
title: "Generative Art with p5.js: Creating Beauty from Mathematics"
description: "Exploring the intersection of code and creativity through generative art experiments."
pubDate: "Feb 18 2024"
image: "https://images.unsplash.com/photo-1561070791-2526d30994b5?w=400&auto=format&fit=crop&q=60"
authorImage: "/avatar/avatar1.png"
authorName: "Neeldhara"
---
# Generative Art with p5.js: Creating Beauty from Mathematics
Code becomes canvas when mathematics meets creativity.
## Today's Creation: Perlin Noise Flows
```javascript
for (let particle of particles) {
let angle = noise(particle.x * 0.01, particle.y * 0.01, frameCount * 0.001) * TWO_PI;
particle.velocity = p5.Vector.fromAngle(angle);
particle.update();
particle.draw();
}
```
## The Magic of Randomness
Controlled randomness creates organic patterns. Perlin noise gives us randomness with continuity - nature's own algorithm.
## Parameters as Paintbrushes
- Noise scale: Changes pattern density
- Particle count: Affects texture
- Color mapping: Sets the mood
## The Joy of Accidents
The best discoveries come from "mistakes" - a typo that creates unexpected beauty, a parameter pushed to extremes.
## Share Your Creations
Art is meant to be shared. Post your generative experiments and let's inspire each other.

View file

@ -1,40 +0,0 @@
---
title: "Algorithms in Verse: Bubble Sort Sonnet"
description: "Classic algorithms reimagined as poetry - where code meets iambic pentameter."
pubDate: "Feb 22 2024"
image: "https://images.unsplash.com/photo-1455390582262-044cdead277a?w=400&auto=format&fit=crop&q=60"
authorImage: "/avatar/avatar1.png"
authorName: "Neeldhara"
---
# Algorithms in Verse: Bubble Sort Sonnet
## Bubble Sort: A Sonnet
```
Compare adjacent elements in pairs,
If order's wrong, then swap them into place.
Through all the list this simple rule declares:
The largest bubbles up to find its space.
Again we start, but now one less to check,
The second largest finds its rightful home.
Each pass through makes the chaos less a wreck,
Until at last no elements must roam.
Though simple in its elegance and grace,
And easy for beginners to perceive,
In practice, it's too slow to win the race—
O(n²) we sadly must believe.
But beauty lies in simplicity's pure art,
The bubble sort still teaches at the start.
```
## The Challenge
Can you write Quicksort as a limerick? Or Binary Search as free verse?
## Why This Matters
Poetry forces us to find the essence of an algorithm. The constraint reveals understanding.

View file

@ -1,56 +0,0 @@
---
title: "Code Haikus: Programming in 5-7-5"
description: "Expressing programming concepts through the constrained beauty of haiku."
pubDate: "Jan 30 2024"
image: "https://images.unsplash.com/photo-1481627834876-b7833e8f5570?w=400&auto=format&fit=crop&q=60"
authorImage: "/avatar/avatar1.png"
authorName: "Neeldhara"
---
# Code Haikus: Programming in 5-7-5
The constraint of haiku forces clarity. Here are programming concepts distilled to their essence.
## On Recursion
```
Function calls itself
Smaller problems, same pattern
Base case stops the loop
```
## On Debugging
```
Print statements bloom wild
Binary search through the code
Bug reveals itself
```
## On Optimization
```
O(n squared) crawls
Refactor to n log n
Time complexity
```
## On Git Merge Conflicts
```
<<<<<<< HEAD
Your changes, their changes clash
Resolution waits
```
## On Learning
```
Stack Overflow searched
Tutorial incomplete
Understanding dawns
```
## Your Turn
Write a haiku about your coding experience today. The constraint reveals truth.

View file

@ -1,183 +0,0 @@
---
title: "The 100 Prisoners Problem: A Beautiful Puzzle in Probability"
description: "An interactive exploration of one of the most counterintuitive puzzles in probability theory, where 100 prisoners can escape with over 30% chance using a clever strategy."
pubDate: "Oct 13 2025"
image: "https://images.unsplash.com/photo-1589829545856-d10d557cf95f?w=400&auto=format&fit=crop&q=60"
authorImage: "/avatar/avatar1.png"
authorName: "Neeldhara"
---
import PrisonerGameSimulator from '@/components/problems/PrisonerGameSimulator.tsx';
import ProbabilityChart from '@/components/problems/ProbabilityChart.tsx';
import PermutationExplorer from '@/components/problems/PermutationExplorer.tsx';
import StrategyComparison from '@/components/problems/StrategyComparison.tsx';
# The 100 Prisoners Problem
Imagine 100 prisoners, numbered 1 to 100, face an unusual challenge. In a room are 100 boxes, also numbered 1 to 100. Inside each box is a randomly assigned number from 1 to 100 (each number appearing exactly once). The prisoners must find their own number by opening boxes, but here's the catch: **each prisoner can open only 50 boxes**.
The prisoners can devise a strategy beforehand, but once the challenge begins, they cannot communicate. If **all 100 prisoners** find their number, everyone goes free. If even one prisoner fails, all remain imprisoned.
What's the best strategy? And what are the odds of success?
## Try It Yourself!
Before we dive into the mathematics, let's experience the problem firsthand. Below is a simulator where you can play the game yourself. Choose the number of prisoners (between 5 and 100), and then try to help each prisoner find their number by clicking on boxes.
<PrisonerGameSimulator client:only="react" />
---
## The Naive Strategy
The most obvious approach is for each prisoner to simply open 50 random boxes. This seems reasonable, but the probability of success is dismal.
For any single prisoner, the probability of finding their number in 50 random boxes out of 100 is exactly 1/2. Since all 100 prisoners must succeed, and their outcomes are independent under random selection, the probability that everyone succeeds is:
$$P(\text\{success\}) = \left(\frac\{1\}\{2\}\right)^\{100\} \approx 7.9 \times 10^\{-31\}$$
That's essentially zero! You're more likely to win the lottery while being struck by lightning... multiple times.
### Naive Strategy: Probability vs Number of Prisoners
Watch how the probability of success plummets as we increase the number of prisoners:
<ProbabilityChart strategy="naive" client:only="react" />
As you can see, even with just 10 prisoners, the probability drops to about 0.1%. With 100 prisoners, it's practically impossible.
---
## The Clever Strategy: Following the Loops
Here's where mathematics reveals something beautiful. Instead of opening random boxes, each prisoner should follow a simple rule:
1. **Start by opening the box with your own number**
2. **Look at the number inside that box**
3. **Open the box with that number next**
4. **Continue following this chain**
Why does this work? The key insight involves understanding permutations and cycles.
### Understanding Cycles in Permutations
When we randomly assign 100 numbers to 100 boxes, we're creating a **permutation** of the numbers 1 through 100. Every permutation can be decomposed into **cycles**.
For example, if:
- Box 1 contains number 4
- Box 4 contains number 7
- Box 7 contains number 1
Then we have a cycle: 1 -> 4 -> 7 -> 1
Let's explore this with smaller numbers:
<PermutationExplorer client:only="react" />
The interactive explorer above lets you:
- Generate all permutations for small values of *n* (3, 4, or 5)
- See both standard notation and cycle notation
- Filter permutations that have at least one "long cycle" (longer than *n*/2)
- Understand why long cycles matter
### Why This Strategy Works
Here's the crucial insight: **A prisoner succeeds if and only if they are in a cycle of length ≤ 50**.
When prisoner k follows the loop strategy:
1. They start at box k
2. They follow a path through boxes determined by the permutation
3. This path forms a cycle that eventually leads back to box k
4. If this cycle has length ≤ 50, they'll find their number within 50 opens
The prisoners **all succeed** if and only if there is **no cycle longer than 50** in the permutation.
### Calculating the Probability
The probability that a random permutation of 100 elements has no cycle longer than 50 is:
$$P(\text\{success\}) = 1 - \sum_\{k=51\}^\{100\} \frac\{1\}\{k\}$$
Computing this sum:
$$P(\text\{success\}) = 1 - \left(\frac\{1\}\{51\} + \frac\{1\}\{52\} + \cdots + \frac\{1\}\{100\}\right) \approx 0.3118$$
That's over **31%**! This is astronomically better than the naive strategy's probability of essentially zero.
### Loop Strategy: Probability vs Number of Prisoners
<StrategyComparison client:only="react" />
## The Mathematics Behind It
### Why Does the Cycle Length Matter?
In a permutation of n elements, prisoner i will find their number within k tries using the loop strategy if and only if i belongs to a cycle of length at most k.
For n = 100 and k = 50:
- The probability that a specific prisoner is in a cycle of length > 50 is: Σ(j=51 to 100) of 1/100
- But we care about whether ANY prisoner is in such a cycle
- The probability that NO cycle has length > 50 is: 1 - Σ(j=51 to 100) of 1/j
### The Harmonic Series Connection
As *n* approaches infinity, if each prisoner can open *n*/2 boxes, the probability of success approaches:
The limit as n approaches infinity is: P_n = 1 - ln(2) ≈ 0.3069
This beautiful result connects combinatorics, probability, and analysis through the harmonic series!
### Optimality
Remarkably, this loop-following strategy is **optimal**. No other strategy can achieve a higher probability of success. The proof involves showing that the problem reduces to avoiding long cycles in a random permutation, and the loop strategy is the unique way to leverage this structure.
---
## Why This Problem is Beautiful
The 100 prisoners problem is beloved by mathematicians because:
1. **Counterintuitive Result**: The fact that 31% >> 0% is shocking. A seemingly hopeless problem becomes tractable with the right insight.
2. **Deep Connection**: It connects permutation theory, probability, and the harmonic series in an elegant way.
3. **Collaborative Success**: Unlike independent trials, the prisoners' fates are intertwined through the structure of the permutation.
4. **Real-World Metaphor**: It illustrates how understanding underlying structure (cycles in permutations) can dramatically improve outcomes.
---
## Variants and Extensions
### What if prisoners can open k < n/2 boxes?
As k decreases below n/2, the probability drops rapidly. The threshold at n/2 is special—it's where the strategy becomes remarkably effective.
### What about communication?
If prisoners could communicate between trials (but not during), they still can't improve the strategy. The beauty is that the strategy requires only coordination before any prisoner enters, not during.
### The Malicious Director
In an interesting variant, suppose the director can see the prisoners' strategy and arrange the boxes adversarially (not randomly). Can the director always force them to fail? Yes! The director can always create a single cycle of length n, guaranteeing failure.
---
## Conclusion
The 100 prisoners problem shows us that:
- Mathematical structure can be hidden in apparent randomness
- Clever strategies can overcome seemingly impossible odds
- Group coordination can be more powerful than independent action
- Beautiful mathematics often lies beneath simple-seeming puzzles
The next time you face a problem that seems impossible, remember: there might be a hidden structure waiting to be discovered, turning hopeless odds into reasonable ones.
---
## Further Reading
- [Gál, A., & Miltersen, P. B. (2003). "The Cell Probe Complexity of Succinct Data Structures"](https://arxiv.org/abs/cs/0310027)
- [Curtin, E., & Warshauer, M. (2006). "The Locker Puzzle"](https://www.jstor.org/stable/27642173)
- [Wikipedia: 100 Prisoners Problem](https://en.wikipedia.org/wiki/100_prisoners_problem)

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 KiB

View file

@ -0,0 +1,135 @@
---
title: "Two approaches to the 15 puzzle"
description: "Presenting the 15 puzzle: This is a sliding puzzle having 15 square tiles numbered 115 in a frame that is 4 tiles high and 4 tiles wide, leaving one unoccupied tile position. T..."
pubDate: "2021-10-03"
authorName: "Neeldhara"
sourceCategories: ["puzzles", "exposition"]
sourcePath: "15-puzzle/index.qmd"
---
Presenting the [15 puzzle](https://en.wikipedia.org/wiki/15_puzzle):
> This is a sliding puzzle having 15 square tiles numbered 115 in a frame that is 4 tiles high and 4 tiles wide, leaving one unoccupied tile position. Tiles in the same row or column of the open position can be moved by sliding them horizontally or vertically, respectively. The goal of the puzzle is to place the tiles in numerical order.
>
According to Wikipedia, [Johnson & Story (1879)](https://doi.org/10.2307%2F2369492) used a parity argument to show that half of the starting positions for the $n$-puzzle are impossible to resolve, no matter how many moves are made. We are going to explore two approaches* parity-based argument to show that the puzzle shown here on the right is unsolvable.
*I do believe the two proofs are essentially the same with slight differences of language.
![An example of the 15 puzzle](Screenshot_2021-10-03_at_10.36.37_PM.png)
Common to both approaches is the idea of associating a *permutation* with every state of the puzzle. For the purposes of this discussion, we will think of a permutation simply as a sequence of elements. To turn the grid layout into a sequence, you could, for instance, line up the rows next to each other, in other words, read off the numbers from left-to-right and top-to-bottom:
![Associating the puzzle with a permutation](Screenshot_2021-10-03_at_10.45.04_PM.png)
So we think of every puzzle state as a permutation over the set $\{1, 2, \ldots, 15\} \cup \{\star\}$, where we use $\star$ to denote the blank space. For a particular sequence $\sigma$ and an index $1 \leq i \leq 16$, we will use $\sigma_i$ to refer to the element that is at the $i^{th}$ position in the sequence $\sigma$.
A couple of definitions in the context of permutations will be useful:
- An *inversion* is a pair of elements that is out of their natural order. More precisely, if we have indices $i < j$ such that $\sigma_i > \sigma_j$, then the pair $(i,j)$ indulges in an inversion. Note that the starting state of our puzzle here has exactly one inversion.
- A *transposition* of locations $i$ and $j$ **is essentially a swap of the elements at positions $i$ and $j$ of a given permutation. So this is an operation performed on a permutation. Let's say this again with more explicit notation — if we start with $\sigma$, then the permutation $\tau$ obtained from $\sigma$ by a transposition of $i$ and $j$ is given by the following:
$$
\tau_\ell = \begin{cases}
\sigma_j & \text{if } \ell = i,\\
\sigma_i & \text{if } \ell = j,\\
\sigma_\ell & \text{otherwise.}
\end{cases}
$$
The identity permutation, which we will denote by $\iota$, is special — it's the following sequence:
$$
\{1,2,\ldots,14,15,\star\}.
$$
It turns out that *every permutation* $\sigma$ can be obtained from the identity permutation by a sequence of transpositions. This is not terribly hard to see — start with the identity permutation, and repeat the following until the permutation at hand is the one you want to see: find a location $i$ that's messed up in the current permutation, i.e, it doesn't have the element you need in there. Find where the element is in the current permutation, and if that's location $j$, you could perform a transposition between $i$ and $j$. This fixes up the location $i$. In every step, you fix at least one location, and never mess up anything else: so at the end of at most $n$ steps (assuming you are working with a sequence of $n$ elements), you would be done. 🎉
For example, suppose the permutation you want to obtain is 3,4,2,1. Here is how the argument above would play out:
1. 1,2,3,4. The first location is messed up, so swap 1 and 3.
2. 3,2,1,4. The second location is messed up, so swap 2 and 4.
3. 3,4,1,2. The third location is messed up, so swap 1 and 2.
4. 3,4,2,1. Now we are done.
Note that this may not be the only way of performing a sequence of transpositions that can morph $\iota$ into $\sigma$ — there may be various roads to $\sigma$. However, it turns out that no matter what route you take to transform $\iota \longrightarrow \sigma$, the *number of steps you perform will always have the same parity.* So specifically, it's *not possible* for you to have a series of, say, seventeen transpositions that turn $\iota$ into $\sigma$, and for me to have a series of forty-two transpositions that do the same. We will take this ~~as a cute exercise for the reader~~ as given.
This partitions the set of all permutations into two categories:
- **even permutations:** those permutations that are reachable from the identity with an even number of transpositions
- odd **permutations:** those permutations that are reachable from the identity with an odd number of transpositions
The fact from the previous paragraph above makes this classification unambiguous.
Alright, so now we have all the terminology we need to get to the argument about why the puzzle state we started with is unsolvable. We can roll up our sleeves and get started.
---
The first line of argument is based on [this Numberphile video](https://www.youtube.com/watch?v=YI1WqYKHi78&vl=en), and is also the one described [in this 1999 American Math Monthly article by Archer](https://www.cs.cmu.edu/afs/cs/academic/class/15859-f01/www/notes/15-puzzle.pdf). We begin with the observation that every move in the game is really a transposition behind the scenes. In particular, let's say that we are currently in state $s$ and we perform some move and move to state $t$. Let's say the permutation associated with $s$ was $\sigma$ and the permutation associated with $t$ is $\tau$. It's not hard to see that:
- $\tau$ can be obtained from $\sigma$ with a single transposition.
Now, note that the permutation corresponding to our target state is the following:
![The permutation corresponding to our target state](Screenshot_2021-10-03_at_11.04.12_PM.png)
In terms of the game state, notice that the final state has the blank tile at the bottom-right corner, just like we had at the start state. This means that in a hypothetical sequence of moves that morphs the initial game state into this solved state, we must have performed:
- an equal number of left and right moves; and
- an equal number of up and down moves.
If this is not the case — imagine the blank tile traveling through the board as you perform the moves — if the number of times you moved in opposite directions did not exactly cancel, it would be impossible for the blank location to be back at it's original location.
So in any winning sequence, the number of moves performed must be even. This implies that the permutation corresponding to the start state, in particular, can be obtained from the identity permutation with an even number of transformations. That makes the starting permutation an even permutation.
However, the permutation corresponding to the start state that we have been handed out is clearly an odd permutation: it can be obtained from the identtiy permutation by a transposition of the elements at the 14-th and 15-th positions. So, well, no dice! This shows that every solvable state that places a blank tile at the bottom-right corner must correspond to an even permutation. This does *not* automatically imply that all such states associated with even permutations are solvable* — it just shows that states with blank tiles at the bottom-right corner corresponding to odd permutations are firmly out of reach.
*It does turns out that all even permutations are in fact solvable.
---
The second approach is based on the notion of inversions. This one is based on [the Strong Induction lecture](https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-042j-mathematics-for-computer-science-fall-2010/video-lectures/lecture-3-strong-induction/) in the MITOCW course on Mathematics for Computer Science. For this proof I'll actually switch to the $3 \times 3$ version of the puzzle because ~~I don't know how to extend it to the 15-puzzle~~ the case analysis is more manageable for this version:
![A move in the 3 X 3 version of the puzzle](Screenshot_2021-10-03_at_11.30.57_PM.png)
As we said before, the permutation associated with the starting point of the puzzle has exactly one inversion, while the permutation associated with the solved state, which is the identity permutation, has no inversions. So, when you make a move in the puzzle, what happens to the number of inversions?
As before, let's say that we are currently in state $s$ and we perform some move and move to state $t$. Let's say the permutation associated with $s$ was $\sigma$ and the permutation associated with $t$ is $\tau$. Let us say that a pair of elements $(p,q)$ is affected by a move in the game if the relative order of $p$ and $q$ is different in the permutations $\sigma$ and $\tau$. Now we have the following:
- if we perform a row move, the relative order of all elements corresponding to numbers remains the same — in particular, all affected pairs involve $\star$ — so the number of inversions in $\tau$ is exactly the same as the number of inversions in $\sigma$.
- if we perform a column move, typically the element that is being moved, say $p$, ends up effectively jumping over two other elements, say $a$ and $b$. In this case the following scenarios arise:
- Neither $(p,a)$ nor $(p,b)$ is an inversion in $\sigma$.
![Neither $(p,a)$ nor $(p,b)$ is an inversion in $\sigma$](Screenshot_2021-10-03_at_11.51.03_PM.png)
- In this case, *both* $(p,a)$ and $(p,b)$ emerge as new inversions in $\tau$, and the total number of inversions in $\tau$ is two *more* than the total number of inversions in $\sigma$.
- Both $(p,a)$ and $(p,b)$ are inversions in $\sigma$.
![Both $(p,a)$ and $(p,b)$ are inversions in $\sigma$](Screenshot_2021-10-03_at_11.53.09_PM.png)
- In this case, *neither* $(p,a)$ nor $(p,b)$ are inversions in $\tau$ — they both get fixed! So the total number of inversions in $\tau$ is two *less* than the total number of inversions in $\sigma$.
- While $(p,a)$ is an inversion in $\sigma$, $(p,b)$ is not.
![While $(p,a)$ is an inversion in $\sigma$, $(p,b)$ is not](Screenshot_2021-10-03_at_11.54.46_PM.png)
- In this case, you fix some, you spoil some — so in $\tau$, $(p,a)$ is not an inversion any more, but $(p,b)$ emerges as a new inversion; so the changes cancel and the number of inversions in $\tau$ is exactly the same as the number of inversions in $\sigma$.
- While $(p,a)$ is not an inversion in $\sigma$, $(p,b)$ is one.
![While $(p,a)$ is not an inversion in $\sigma$, $(p,b)$ is one](Screenshot_2021-10-03_at_11.53.39_PM.png)
- As before, you fix some, you spoil some just the other way now — so in $\tau$, $(p,a)$ is a new inversion, but $(p,b)$ is no longer one; so the changes cancel again and the number of inversions in $\tau$ is exactly the same as the number of inversions in $\sigma$.
The long and short of all this is that after every move, the number of inversions *either remains the same or changes by two.* So no matter how many moves you perform, a state whose associated permutation has an odd number of inversions is going to remain inaccessible.
Tada!
---
So there we have it... I have a feeling that a little bit of language connecting transpositions and inversions will really make these proofs quite identical, at least for the $3 \times 3$ case — although I did worry that the first approach seemed to rely rather explicitly on the location of the blank tile while the second one didn't. It is quite possible that the first one actually demonstrates more than I'm giving it credit for!
Meanwhile, to be honest, I haven't thought much about pushing the second line of attack to the $4 \times 4$ case — it seems already that the statement about the change in the number of inversions is no longer true and the change itself is no longer two: in particular, it could apparently go up or down by three or one instead, since the element involved in the action, $p$ is now potentially jumping over *three* other elements, $a$, $b$, and $c$... so this, at least from an immediate consideration, doesn't quite take us where we want to go.
Possibly one has to work with a somewhat different invariant, maybe a notion of inversions that involve triples instead of pairs? Any comments on this would be very welcome, and I'll have an update once I understand this a little better!

View file

@ -0,0 +1,172 @@
---
title: "Dog Bunny Puzzle"
description: "Dog Bunny: A Cute Puzzle Conrad Barski (@lisperati)'s latest, Dog Bunny Puzzle, had jumped to 1 on HN. The puzzle presents the following somewhat minimalist interface: If you ha..."
pubDate: "2022-09-19"
authorName: "Neeldhara"
sourceCategories: ["puzzles", "exposition"]
sourcePath: "dogs-bunny-puzzle/index.qmd"
---
### Dog Bunny: A Cute Puzzle
Conrad Barski ([@lisperati](https://twitter.com/lisperati))'s latest, [Dog Bunny Puzzle](http://www.dogbunnypuzzle.com/), had [jumped to #1 on HN](https://news.ycombinator.com/item?id=32884467). The puzzle presents the following somewhat minimalist interface:
![The Dogs Bunny Puzzle](puzzlescreenshot.png)
If you haven't played it yet, you might want to go ahead and [give it a shot](http://www.dogbunnypuzzle.com/) first. Most people figured out the mechanics without any explicit instructions. A couple of things that may not be immediately clear, but typically discovered quickly within a few moves:
- The edges are labeled with conditions, and can be used only if _all_ of the said conditions are met.
- The bunny or dog icons may sometimes cover up what kind of location they are at. You can drag them away to find out!
- Multiple animals can occupy the same spot at a time.
- It is possible to get into a dead end, a situation from where no legal moves are possible. In the verison of the game that is available at the time of this writing, the game offers no sign that you might be in this situation. This may [however change](https://twitter.com/lokshtanov/status/1571597503795167232).
After winging it on the puzzle, several questions seemed natural:
> **Note**
>
> ### What's the smallest number of moves to win?
> [Apparently 26.](https://gist.github.com/wrbs/5824e9b17c55b5ad3d8467f93e12ed8b)
> **Note**
>
> ### Can you write a program to find a solution?
> [Yes](https://github.com/polkerty/dog-bunny-puzzle-solver/blob/master/main.py) (Python) and [yes](http://hakank.org/picat/dogbunny_puzzle.pi) (Picat).
> **Note**
>
> ### Can a script generate more of these puzzles?
> Indeed:
>
> <blockquote class="twitter-tweet" data-conversation="none"><p lang="en" dir="ltr">For those paying attention, yes I am two days late :(<br><br>FYI, I also have a program now that can create an infinite number of these puzzles at differing difficulty<br><br>How would you rate the puzzle I posted today?</p>&mdash; Conrad Barski (@lisperati) <a href="https://twitter.com/lisperati/status/1571232335043112960?ref_src=twsrc%5Etfw">September 17, 2022</a></blockquote>
>
> **Note**
>
> ### Are there connections with other well-known puzzles?
> Why yes, check out the [Wolf puzzle](https://en.wikipedia.org/wiki/Wolf,_goat_and_cabbage_problem) (as pointed out by [@RianNeogi](https://twitter.com/RianNeogi/status/1571608738791817217)) and this [Numberphile video](https://www.youtube.com/watch?v=ZCVAGb1ee8A) about it.
> **Note**
>
> ### Is the problem NP-complete?
>
> Before you ask, [I am not the only one](https://twitter.com/gfredericks_/status/1571247392321671174) who's asking!
>
So the last question may strike you as a bit left-field, but that's what I'm going to ramble about for the rest of this post :) It turns out that the answer is in the affirmative, and [here](https://twitter.com/lokshtanov/status/1571588360254410752) is a lovely reduction by [@lokshtanov](https://twitter.com/lokshtanov) showing as much.
### The Reduction
Let's just set up the game as a computational problem just to be sure that we agree on the abstraction. In fact, we'll be working with a simpler version that we will call `BunnyCarrot`.
> **Tip**
>
> ### BunnyCarrot
>
> In the `BunnyCarrot` problem, the input is a simple undirected graph $G = (V,E)$, subsets $B$ and $C$ of $V$ indicating the initial positions of bunnies and carrots, and a (possibly empty) instruction $r_e$ for every $e \in E$, which is a collection of conditions, _at least_ one† of which must be true for the edge $e$ to be "active".
>
> The question is if there is a sequence of movements of bunnies along active edges such that at the end of the sequence, every bunny is located at one of the vertices from $C$.
>
> † In the original version of the problem, we need _all_ conditions associated with an edge to be satisfied, not at least one. The construction that we will describe can be easily adapted to this setting as well, but is simpler to describe for this variant :)
We are going to show that `BunnyCarrot` is NP-complete by reducing from `3SAT`. So let $\phi := \{C_1, \ldots, C_m\}$ be a collection of $m$ 3SAT clauses over variables $\{x_1, \ldots, x_n\}$. The reduced instance of `BunnyCarrot` corresponding to $\phi$ looks like this:
![A cartoon sketch of the reduced instance of BunnyCarrot from 3SAT.](reduction2.png)
What we have here is the following in terms of the structure of graph:
- a path $X$ on $m+2$ vertices, with the left most vertex in $B$ and the rightmost one in $C$;
- a pair of vertices $(u_i,v_i)$ for every $i \in [n]$, and an edge between them, where all the $u_i$'s are in $B$' --- the vertex $u_i$ represents the literal $x_i$ while the vertex $v_i$ represents the literal $\overline{x_i}$;
- a pair of vertices $p$ and $q$ in $C$, with $p$ adjacent to all $u_i$'s and $q$ adjacent to all $v_i$'s.
Now here be the instructions associated with the edges:
- the edge to the $\ell$-th vertex on $X$ is active only if there is a bunny on at least one of the literals present in the clause $C_{\ell-1}$;
- the edges between $u_i$ and $v_i$ are active only when there is a bunny on the leftmost vertex of $X$; and
- finally, the edges incident on $p$ and $q$ are active only when there is a bunny on the rightmost vertex of $X$.
### The Forward Direction
We first claim that we can "win" this game if $\phi$ has a satisfying assignment. Indeed, let $$\tau: \{x_1,\ldots,x_n\} \rightarrow \{0,1\}$$ be a truth assignment that satisfies all the clauses of $\phi$. Then:
1. If $\tau(x_i) = 0$, move the bunny on $u_i$ to $v_i$.
2. Move the bunny on the leftmost vertex of the path $X$ to the rightmost vertex: note that all edges are active because $\tau$ is a satisfying assignment.
3. Move all bunnies on $u_i$'s to $p$ and those on $v_i$'s to $q$.
### The Backward Direction
Now suppose there is a winning sequence of moves $\sigma$. We will show that we can extract from this sequence a satisfying assignment for $\phi$, which will firmly establish the equivalence of the generated instance of `BunnyCarrot` with the OG hard instance $\phi$.
Note that to begin with, all the blue edges are inactive. Now, in the sequence $\sigma$, let us say that a step is _key_ if it involves a bunny moving along the first edge of the path $X$ and _critical_ if it involves a bunny moving along the last edge of the path $X$.
Suppose the $\ell$-th step is the first critical step in $\sigma$. Further, suppose that the $t$-th step is the _last_ key step to occur _before_ the $\ell$-th step. Notice that there must be at least one key step before a critical step --- we must begin before we can end :)
Now, for all steps after the $t$-th step and before the $\ell$-th step, note that edges incident to $u_i$ and $v_i$ are **inactive** for all $i \in [n]$. This implies that every step between the $t$-th and $\ell$-th steps involves a bunny moving along $X$, and in particular, every edge in $X$ is crossed at least once in this phase of the game.
Let us note the positions of the bunnies who are on the $u_i$'s and $v_i$'s after the $t$-th step is executed. Observe that this naturally translates to an assignment on the variables as follows:
$$
\begin{equation*}
\tau(x_i) =
\begin{cases}
1 & \text{if } u_i \in B,\\
0 & \text{if } v_i \in B.
\end{cases}
\end{equation*}
$$
We argue that $\tau$ must in fact be a satisfying assignment.
Assume to the contrary: suppose some clause $C_k$ is, in fact, not satisfied by $\tau$.
Then, we claim that the edge connecting the $k$-th and $(k+1)$-th vertices is not active.
As an example, suppose $C_k = \{x_1,x_2,\overline{x_3}\}$. Since $\tau$ does not satisfy $C_k$, it must be the case that:
- $\tau(x_1) = 0$ --- and hence there is a bunny on $v_1$;
- $\tau(x_2) = 0$ --- and hence there is a bunny on $v_2$;
- $\tau(x_3) = 1$ --- and hence there is a bunny on $u_3$.
However, the condition for the edge to the $(k+1)$-th vertex on $X$ to be active is simply that there is a bunny present on at least one of the literals present in the clause $C_{k}$, i.e, one of $u_1$, $u_2$ or $v_3$. However, because of the structure of the graph, and the fact that all edges incident on $p$ and $q$ are inactive at all times before the first critical step, observe that:
- If there is a bunny on $v_1$, there is no bunny on $u_1$.
- If there is a bunny on $v_2$, there is no bunny on $u_2$.
- If there is a bunny on $u_3$, there is no bunny on $v_3$.
By our assumption that $\tau$ falsifies $C_k$, _all_ the premises above are true! So there is an edge on the path $X$ that is not active between the $t$-th and $\ell$-th steps, which violates our understanding that every edge was crossed between these steps. This is a contradiction, and hence $\tau$ must indeed be a satisfying assignment.
I'll just remark here that this construction can be modified so that every vertex in the graph has constant degree, and there is only one vertex in $C$. It can also be modified to change the "or" condition on the edges to an "and", by simply separating the conditions out along multiedges.
### Food for thought
Here are some more questions :)
> **Important**
>
>
> 1. What's the complexity of this game when the underlying graph has some simple structure (e.g, a tree)?
>
> 2. Does the problem get harder if we introduce attacking entities like wolves?
>
> 3. Can we come up with an algorithm that runs in polynomial time on instances where there is a valid winning sequence of constant length?
>
> 4. Is the problem hard even for a constant number of bunnies?
PS. Here's [a sketch of a slighty different reduction](https://twitter.com/neeldhara/status/1571522626526515202) from vertex cover. Thanks again to [Daniel](https://twitter.com/lokshtanov) for sharing the reduction described here! Comments welcome here, or [continue the conversation on Twitter](https://twitter.com/neeldhara/status/1571629379779973121)!

Binary file not shown.

After

Width:  |  Height:  |  Size: 432 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 KiB

View file

@ -1,32 +0,0 @@
---
title: "Dynamic Programming: Hidden Gems from Recent Contests"
description: "Elegant dynamic programming problems that showcase beautiful techniques and insights."
pubDate: "Jan 25 2024"
image: "https://images.unsplash.com/photo-1509228468518-180dd4864904?w=400&auto=format&fit=crop&q=60"
authorImage: "/avatar/avatar1.png"
authorName: "Neeldhara"
---
# Dynamic Programming: Hidden Gems from Recent Contests
These problems demonstrate the art of dynamic programming beyond standard patterns.
## Problem 1: The Subsequence Symphony
Given a string, find the number of subsequences that form palindromes of prime length.
### Solution Insight
The key is to maintain DP states for both position and palindrome center simultaneously. This reduces the state space from O(n³) to O(n²).
## Problem 2: Graph Coloring with Constraints
Color a graph such that no two adjacent vertices share a color, and the total number of color changes along any path is minimized.
### The DP Formulation
DP[node][color][changes] gives us the minimum cost. The trick is recognizing that we only need to track changes modulo 2.
## Practice Makes Perfect
These problems teach us that DP is as much about problem modeling as it is about computation.

View file

@ -1,41 +0,0 @@
---
title: "The Four Aces Miracle: A Self-Working Mathematical Marvel"
description: "A card trick that teaches modular arithmetic and probability - perfect for the classroom."
pubDate: "Jan 28 2024"
image: "https://images.unsplash.com/photo-1529480384838-c1681c84aca5?w=400&auto=format&fit=crop&q=60"
authorImage: "/avatar/avatar1.png"
authorName: "Neeldhara"
---
# The Four Aces Miracle: A Self-Working Mathematical Marvel
This trick never fails to amaze students, and the mathematics behind it is even more amazing.
## The Effect
A spectator deals cards into four piles while making random choices. Impossibly, the four aces end up on top of each pile.
## The Secret
It's all about invariants and modular arithmetic. No sleight of hand required - pure mathematics does the magic.
## The Method
1. Pre-arrange the deck (the math determines the arrangement)
2. Have the spectator deal following simple rules
3. The aces appear automatically
## The Mathematics
The dealing process preserves certain positional invariants modulo 4. The initial arrangement ensures these invariants place the aces correctly.
## Teaching Applications
This trick demonstrates:
- Modular arithmetic
- Invariants in algorithms
- Deterministic vs. random processes
## The Bigger Lesson
Mathematics can create experiences that feel like magic. And that feeling of wonder? That's what hooks students on math.

View file

@ -1,35 +0,0 @@
---
title: "The Gilbreath Principle: When Chaos Creates Order"
description: "A mathematical card principle that seems impossible but always works - perfect for teaching algorithms."
pubDate: "Feb 15 2024"
image: "https://images.unsplash.com/photo-1570543375343-63fe3d67761b?w=400&auto=format&fit=crop&q=60"
authorImage: "/avatar/avatar1.png"
authorName: "Neeldhara"
---
# The Gilbreath Principle: When Chaos Creates Order
Shuffle a deck in a specific way, and mathematical order emerges from apparent chaos.
## The Phenomenon
Arrange cards alternating red-black. Riffle shuffle. Now deal pairs - each pair has one red and one black card. Magic? No, mathematics.
## Why It Works
The riffle shuffle preserves local structure while appearing to randomize. The alternating pattern creates an invariant that survives the shuffle.
## Classroom Implementation
Students predict it won't work. When it does, they're hooked. "Why?" becomes the driving question.
## The Deeper Lesson
Not all randomness is truly random. Structure can hide in apparent disorder. This principle appears in:
- Network protocols
- Error-correcting codes
- Distributed systems
## Beyond Cards
The Gilbreath Principle teaches us to look for hidden invariants in complex systems.

View file

@ -1,32 +0,0 @@
---
title: "Graph Algorithms: Assessment Highlights"
description: "Interesting graph problems from recent course assessments with detailed solutions."
pubDate: "Feb 28 2024"
image: "https://images.unsplash.com/photo-1550751827-4bd374c3f58b?w=400&auto=format&fit=crop&q=60"
authorImage: "/avatar/avatar1.png"
authorName: "Neeldhara"
---
# Graph Algorithms: Assessment Highlights
A collection of graph problems that test deep understanding rather than memorization.
## The Bridge Detection Variant
Find all edges whose removal increases the number of triangles in the graph.
### Solution Approach
Counter-intuitively, we need to count triangles that share exactly one edge with the candidate. The algorithm runs in O(m√m) time using careful enumeration.
## Shortest Path with Wildcards
Given a graph where some edge weights are variables, find assignments that minimize the longest shortest path.
### Key Insight
This reduces to a linear programming problem with interesting structure. The dual interpretation reveals connections to network flow.
## Teaching Through Problems
These problems help students see beyond standard algorithms to underlying principles.

View file

@ -1,41 +0,0 @@
---
title: "IOI 2023: Breaking Down the Hardest Problems"
description: "Deep analysis of the most challenging problems from the International Olympiad in Informatics 2023."
pubDate: "Jan 20 2024"
image: "https://images.unsplash.com/photo-1434030216411-0b793f4b4173?w=400&auto=format&fit=crop&q=60"
authorImage: "/avatar/avatar1.png"
authorName: "Neeldhara"
---
# IOI 2023: Breaking Down the Hardest Problems
The International Olympiad in Informatics continues to push the boundaries of algorithmic problem solving.
## Problem: Soccer Stadium
A geometric optimization problem disguised as dynamic programming. The key insight: think in terms of monotonic paths.
### The Approach
1. Transform the 2D problem into a 1D problem using clever observations
2. Use convex hull optimization for the DP transitions
3. Handle edge cases with careful implementation
## Problem: Closing Time
A tree problem requiring sophisticated data structures and careful analysis.
### The Solution
The trick is recognizing this as a centroid decomposition problem. Once you see it, the implementation follows naturally.
## Lessons for Students
These problems teach us:
- Simple problems have elegant solutions
- Complex problems require systematic decomposition
- Implementation matters as much as algorithms
## Practice Strategy
Start with subtasks. Even partial solutions teach valuable lessons.

View file

@ -1,35 +0,0 @@
---
title: "The Knight's Tour: An Interactive Exploration"
description: "An interactive puzzle exploring the knight's tour problem with surprising mathematical connections."
pubDate: "Jan 30 2024"
image: "https://images.unsplash.com/photo-1528819622765-d6bcf132f793?w=400&auto=format&fit=crop&q=60"
authorImage: "/avatar/avatar1.png"
authorName: "Neeldhara"
---
# The Knight's Tour: An Interactive Exploration
Can a knight visit every square on a chessboard exactly once? This ancient puzzle hides deep mathematical structure.
## The Basic Challenge
Start with a 5×5 board. Can you find a knight's tour? What about one that returns to the starting square (a closed tour)?
## Mathematical Beauty
The problem connects to:
- Hamiltonian paths in graphs
- Warnsdorff's heuristic
- Magic squares (surprisingly!)
## The Algorithm
The key insight: always move to the square with fewest onward moves. This simple heuristic works remarkably well.
## Try It Yourself
[Interactive board would go here - imagine clicking squares to build your tour]
## Going Deeper
For which board sizes do closed tours exist? The answer involves beautiful number theory.

View file

@ -0,0 +1,52 @@
---
title: "Moving Blocks at CTIS 2021"
description: "I am very excited about third conference on Computational Thinking in Schools (CTiS2021)[^1], a CSpathshala event, that's coming up from the 29th September to 2nd October 2021 a..."
pubDate: "2021-09-21"
authorName: "Neeldhara"
sourceCategories: ["puzzles", "exposition"]
sourcePath: "moving-blocks-ctis/index.qmd"
---
I am very excited about [third conference on Computational Thinking in Schools](https://sites.google.com/view/ctis2021/home?authuser=0) (CTiS2021)[^1], a [CSpathshala](https://www.google.com/url?q=https%3A%2F%2Fcspathshala.org%2F&sa=D&sntz=1&usg=AFQjCNHh6bbDDYykMp9_oAWqw9PhiDHKPg) event, that's coming up from the 29th September to 2nd October 2021 at School of Scholars, Nagpur.
[^1]: Registration is free but mandatory. The deadline is 28th September. Please [head over here](https://sites.google.com/view/ctis2021/registration?authuser=0) to register!
Some background from the conference website:
> The CTiS (Computational Thinking in Schools) conference is an annual event organised by the ACM (Association of Computing Machinery) and the CSpathshala community. It aims to bring together teachers, educators and researchers to discuss issues of curriculum, pedagogy, policy and implementation, related to bringing computational thinking to schools.
CTiS2021 aims to provide a platform for teachers, educators and experts to share their best practices as well as challenges faced in implementing computational thinking in education. The discussions will focus on integrating CT activities (both plugged and unplugged) in various school subjects, on student learning outcomes and on disseminating findings of CT based experiments or classroom research conducted by teachers and educators across the country.
Our 4-day conference features key note speakers, Hal Abelson, MIT, USA, Manish Jain, IIT Gandhinagar, Patricia Ordóñez, University of Puerto Rico Río Piedras and Wolfgang Slany, TU Graz, Austria. The conference also features a workshop on CT and inclusion, conducted by Supriya Dey, Vision Empower and Manohar Swaminathan, Microsoft Research, Bengaluru and presentations of selected abstracts with sessions on implementation of computational thinking, fun activities and innovative examples used by teachers in classrooms!
Needless to say, I'm looking forward to this very exciting program! As a PC member, I also know that the contributed content is fantastic as well, and the aim of this little writeup is to offer a glimpse into this section of the conference.
In particular, I want to share with you a puzzle that was described by Rema Nair, who teaches Computer Science at the Mallya Aditi International School in Bangalore, grades 9-12.
To begin with, we have an equal number of blue and green boxes positioned as follows:
🟦 🟦 🟦 🟩 🟩 🟩
So the blue boxes are lined up first from left to right, followed by a space that's exactly enough to fit one box, and then we have the green boxes lined up after the space. The goal is to arrive at the following position, which is essentially what you would have if the blue and green boxes were to switch positions:
🟩 🟩 🟩 🟦 🟦 🟦
The moves of the boxes are subject to the following rules:
- The boxes from the left (i.e, the blue ones) can only move towards the right, and the boxes from the right (i.e, the green ones) can only move towards the left.
- Boxes can move forward one space, or move two spaces by jumping over/moving past another box of a different colour (never over a box of the same colour).
- The moves are to be made in one direction only.
The puzzle is solved when the two sets of boxes have switched positions.
So how would you get the boxes to switch positions? Are there multiple ways to do it successfully? If so, which strategy leads to the smallest number of moves? This should be a fun conversation-starter in class — and beyond!
This is a great activity with actual boxes in a physical setting, but for now, here's a quick version that you can try out right here, thanks to [Polypad](https://mathigon.org/polypad) by [Mathigon](https://mathigon.org)* - be careful to not overlap the boxes one on top of the other, they will end up merging! You can always refresh this page to reset 😀
*Note that the numbers on the boxes are immaterial; notice that given the constraints on the directions, the relative ordering of the numbers is fixed anyway.
Enjoy playing for now, and [join us at CTiS](https://sites.google.com/view/ctis2021/registration?authuser=0) to meet Rema (and other participants).
<iframe width="720" height="440" src="https://mathigon.org/polypad/embed/y191NxerHKiwg" frameborder="0" allowfullscreen></iframe>

View file

@ -1,35 +0,0 @@
---
title: "Project Euler: My Favorite Problems from 700+"
description: "Curated problems from Project Euler that teach beautiful mathematical and algorithmic concepts."
pubDate: "Feb 25 2024"
image: "https://images.unsplash.com/photo-1635070041078-e363dbe005cb?w=400&auto=format&fit=crop&q=60"
authorImage: "/avatar/avatar1.png"
authorName: "Neeldhara"
---
# Project Euler: My Favorite Problems from 700+
After solving 700+ Project Euler problems, these are the ones that changed how I think about mathematics and programming.
## Problem 96: Su Doku
Not just Sudoku solving - but solving 50 puzzles efficiently. The beauty is in combining constraint propagation with backtracking.
## Problem 208: Robot Walks
A counting problem that requires deep mathematical insight. The connection to complex numbers is unexpected and beautiful.
## Problem 613: Pythagorean Ant
Probability meets geometry in this elegant problem. The solution requires careful integration and surprising symmetry observations.
## The Meta-Lesson
Project Euler teaches you:
- Mathematical intuition matters more than coding speed
- There's always a clever approach
- The journey matters more than the destination
## Getting Started
Don't aim for the leaderboard. Aim for understanding. Each problem is a teacher.

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View file

@ -0,0 +1,114 @@
---
title: "Solo Chess"
description: "Putting this thread in one place. --- 🧵 on our latest at FUN 2022 with @NRAravind1 and Harshil. Have you tried Solo Chess @chesscom yet? Its addictive — and NP-complete even w..."
pubDate: "2022-03-24"
authorName: "Neeldhara"
sourceCategories: ["exposition", "twitterthread"]
sourcePath: "solo-chess/index.qmd"
---
Putting [this thread](https://twitter.com/neeldhara/status/1506794212590768130) in one place.
---
🧵 on our latest at FUN 2022 with [@NRAravind1](https://twitter.com/NRAravind1) and Harshil.
Have you tried Solo Chess [@chesscom](https://twitter.com/chesscom) yet? Its addictive — and NP-complete* even when youre dealing only with rooks!
*when appropriately generalized
![The Rules of the Game](FOk1WJZXwAUb7V7.jpg)
So this is a single-player, peg-solitaire-ish chess variant, where you have to clear board by making a sequence of valid captures, albeit starting with unorthodox — and even unrealistic — positions.
![An example position](CleanShot_2022-03-24_at_04.30.34.png)
To begin with the boards start easy, with a few pieces at a time. Notice, even in the early games, how some positions have just one solution while others may have several.
![More positions](CleanShot 2022-08-30 at 08.46.16.png)
From initial plays, you sense that it has a very Hamiltonian-Path-ish vibe, and feels like youre trying to find a path in *some* graph 😅
We started with a variant that was simultaneously a generalization and specialization:
- n pieces 😎
- ♖s only
- 1D boards 🙈
This, it turns out, is case so special that its trivial - you can sweep all rooks to the extreme left or extreme right of the board, and any position is winning even if every rook can capture exactly once. Less trivial though: how many ways there are to win? 🤔
We also ask what happens if every rook had a designated number of captures left. Imagine you have a 1D board and three kinds of rooks:
- red rooks cannot move
- blue rooks can move at most once
- green rooks can move at most twice
![1D Boards](CleanShot_2022-03-24_at_04.47.53.png)
We show that such 1D boards can be cleared if and only if then number of green rooks is at least the number of red rooks. This ties nicely with the intuition that every immovable rook needs to be picked up by a rook that can help another one (i.e, > one move left).
This generalizes naturally to rooks with a designated number of moves left, where said number can be anything between 0 and d. Since no other chess piece moves sensibly* across a 1D board, we decided to move on 2D boards from here.
* Kings + rooks is an easy exercise.
So if you are still playing with red, blue, and green rooks, then the problem of checking if a given 2D configuration can be cleared up according to solo chess rules turns out to be NP-complete.
No Hamiltonian Path though — this one was from bipartite dominating set 😎
![A reduction from bipartite dominating set - I](CleanShot_2022-03-24_at_04.58.23.png)
![A reduction from bipartite dominating set - II](CleanShot_2022-03-24_at_04.53.21.png)
Bishops are much the same as rooks, by a 45-degree tilt of the board.
 Still open though: what about the case when all pieces have at most two moves left, which is closer to the original spirit of the game?
We dont know yet, although wed bet its hard, I think.
When playing with queens only, however, we can gadget in the behaviors of red and blue pieces. So we do have that Generalized Solo Chess with just queens that can all move at most twice is NP-complete.
What about pawns? Lets get clarifying assumptions out of the way:
- white pawns only
- regular captures only since theres no premise for en passant captures
In solo chess, pawns are (heavily) constrained bishops: they can only move upwards and to a neighboring diagonal square. Knowing that bishops were hard, but pawns felt simple — we didnt have a bet either way. 🤔
We were pleasantly surprised that the case of pawns is tractable, even when each pawn has a designated* number of moves!
*at most two.
![Lemma for pawns](CleanShot_2022-03-24_at_05.23.22.png)
The algorithm is linear time, too.
Next: what about knights? We dont know yet!
 Whats the complexity of solo chess when played only with knights?
Knights are special because we dont have to worry about obstructions. So the game can be described by a more general token game on graphs:
![The Graph Capture Problem](CleanShot_2022-03-24_at_05.28.55.png)
We do show that Graph Capture is hard by a reduction, again from bipartite dominating set. This might hint at the hardness for Solo Chess played with knights only, but we are not betting on this yet.
![Another reduction from bipartite dominating set - I](CleanShot_2022-03-24_at_05.29.11.png)
![Another reduction from bipartite dominating set - II](CleanShot_2022-03-24_at_05.29.06.png)
I think these preliminary explorations have left us with more questions than answers:
- optimization versions (e.g, clear at least k pieces)
- other constraints (e.g, on distance moved)
- special cases (e.g, O(1) pieces per row/column)
- n x c boards, constant c
While at it, Im also curious about how [@chesscom](https://twitter.com/chesscom) generates these puzzles, and if they have a mechanism for generating ones that have unique solutions. Also, is it true that if you throw “enough” pieces on the board, its solvable WHP?
Shout out to the [skak package](https://ctan.org/tex-archive/fonts/chess/skak) for making it easy to bring chess pieces to TikZ. We expect to put up a preprint on ArXiV soon. 👀  Meanwhile, we welcome comments and feedback — and if you read this far, thanks very much!
PS. Also if you enjoy chess and algorithms, dont miss [Miguel Ambronas](https://miguel-ambrona.github.io/) amazing [Chess Unwinnability Analyzer](https://chasolver.org/), which also appears at FUN 2022!
![Chess Unwinnability](CleanShot_2022-03-24_at_05.56.43.png)
You can find the [full list of accepted papers here](https://sites.google.com/view/fun2022/acceptedpapers).

View file

@ -1,28 +0,0 @@
---
title: "Beyond Sudoku: Exploring Constraint Satisfaction Puzzles"
description: "A journey through Sudoku variants and their algorithmic solutions."
pubDate: "Feb 10 2024"
image: "https://images.unsplash.com/photo-1580541631950-7282082b53ce?w=400&auto=format&fit=crop&q=60"
authorImage: "/avatar/avatar1.png"
authorName: "Neeldhara"
---
# Beyond Sudoku: Exploring Constraint Satisfaction Puzzles
Sudoku is just the beginning. Let's explore variants that push the boundaries of logic puzzles.
## Killer Sudoku
Combine Sudoku with Kakuro - cages show sums, but no digit repeats within a cage.
## Sandwich Sudoku
The numbers outside show the sum of digits between 1 and 9 in that row/column. Simple rule, complex implications!
## The Algorithm Connection
These puzzles are constraint satisfaction problems. Techniques like arc consistency and backtracking with constraint propagation solve them efficiently.
## Create Your Own
What happens if we add chess knight move constraints? The design space is infinite!

View file

@ -1,30 +0,0 @@
---
title: "Imposter Syndrome in Academia: A Confession"
description: "An honest conversation about feeling like a fraud, even after years of success."
pubDate: "Feb 25 2024"
image: "https://images.unsplash.com/photo-1517048676732-d65bc937f952?w=400&auto=format&fit=crop&q=60"
authorImage: "/avatar/avatar1.png"
authorName: "Neeldhara"
---
# Imposter Syndrome in Academia: A Confession
Even after publishing papers, winning grants, and teaching thousands of students, the voice whispers: "They'll find out you don't belong."
## The Paradox
The more you know, the more you realize you don't know. Expertise breeds humility, which feeds the imposter.
## What Helps
- Keeping a "wins" journal - evidence against the imposter
- Mentoring others - seeing your knowledge help someone
- Talking about it - you're not alone in this
## The Silver Lining
Maybe imposter syndrome keeps us humble, curious, and always learning. Maybe it's not a bug, but a feature.
## Moving Forward
I may never silence the voice completely. But I've learned to acknowledge it and keep going anyway.

View file

@ -1,32 +0,0 @@
---
title: "On Teaching Algorithms: Lessons from a Decade"
description: "Reflections on what works (and what doesn't) in computer science education."
pubDate: "Jan 10 2024"
image: "https://images.unsplash.com/photo-1509062522246-3755977927d7?w=400&auto=format&fit=crop&q=60"
authorImage: "/avatar/avatar1.png"
authorName: "Neeldhara"
---
# On Teaching Algorithms: Lessons from a Decade
Ten years of teaching has taught me more than any textbook could.
## Start with Why
Students don't care about O(n log n) until they understand why their code is slow. Real problems first, theory second.
## The Power of Visualization
Abstract concepts become concrete when visualized. Every algorithm should have a picture.
## Failure is a Feature
Let students struggle. The struggle is where learning happens. But know when to throw a lifeline.
## Assessment Philosophy
Test understanding, not memorization. Open-book exams with novel problems beat closed-book regurgitation every time.
## The Joy of "Aha!" Moments
There's no feeling quite like seeing a student's eyes light up when a concept clicks. That's why we do this.

View file

@ -1,34 +0,0 @@
---
title: "SODA 2024: Algorithmic Breakthroughs"
description: "A roundup of fascinating algorithmic results from SODA 2024, focusing on graph algorithms and optimization techniques."
pubDate: "Jan 15 2024"
image: "https://images.unsplash.com/photo-1509228468518-180dd4864904?w=400&auto=format&fit=crop&q=60"
authorImage: "/avatar/avatar1.png"
authorName: "Neeldhara"
---
# SODA 2024: Algorithmic Breakthroughs
The Symposium on Discrete Algorithms (SODA) 2024 brought together researchers from around the world to present cutting-edge algorithmic research. This post highlights some of the most exciting developments in graph algorithms and optimization.
## Graph Algorithms Revolution
### Dynamic Graph Coloring
One of the standout papers introduced a breakthrough in dynamic graph coloring with polylogarithmic update time. The authors developed a novel data structure that maintains a proper vertex coloring while supporting edge insertions and deletions efficiently.
The key insight was to combine randomized recoloring strategies with a carefully designed hierarchical decomposition of the graph. This allows for local updates that rarely propagate through the entire structure.
## Approximation Algorithms
### The Traveling Salesman Problem Revisited
A surprising result showed that for graphs with bounded doubling dimension, we can achieve a (1+ε)-approximation for TSP in nearly linear time. This improves upon decades of previous work and opens new avenues for practical implementations.
## Complexity Theory Connections
The conference also featured several papers bridging the gap between pure algorithmic research and complexity theory. A particularly elegant result showed that certain graph problems believed to require quadratic time are equivalent under fine-grained reductions.
## Looking Forward
These results demonstrate that fundamental algorithmic problems still have room for improvement. The techniques developed here will likely influence algorithm design for years to come.

View file

@ -1,34 +0,0 @@
---
title: "Distributed Computing: Recent Advances"
description: "Survey of recent developments in distributed algorithms from major conferences."
pubDate: "Feb 20 2024"
image: "https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=400&auto=format&fit=crop&q=60"
authorImage: "/avatar/avatar1.png"
authorName: "Neeldhara"
---
# Distributed Computing: Recent Advances
The field of distributed computing has seen remarkable progress in recent years. This post surveys key results from PODC, DISC, and other major venues.
## Consensus Protocols
### Byzantine Agreement in Asynchronous Networks
A breakthrough result achieves optimal resilience with expected constant rounds. The protocol uses cryptographic techniques combined with novel committee selection.
## Distributed Graph Algorithms
### Minimum Spanning Tree in the CONGEST Model
New algorithms achieve near-optimal round complexity for MST construction. The approach uses sophisticated graph decomposition techniques.
## Local Algorithms
### The Power of Local Computation
Recent work characterizes which problems admit constant-time local algorithms. The classification provides a complete picture for bounded-degree graphs.
## Future Directions
The intersection of distributed computing with machine learning presents exciting opportunities for both fields.

View file

@ -1,54 +0,0 @@
---
title: "Git Workflows That Save My Sanity"
description: "Automation scripts and Git hooks that eliminate repetitive tasks and prevent common mistakes."
pubDate: "Jan 22 2024"
image: "https://images.unsplash.com/photo-1556075798-4825dfaaf498?w=400&auto=format&fit=crop&q=60"
authorImage: "/avatar/avatar1.png"
authorName: "Neeldhara"
---
# Git Workflows That Save My Sanity
After years of Git mishaps, I've built workflows that prevent disasters and save hours weekly.
## The Pre-commit Hook That Saves Embarrassment
```bash
#!/bin/bash
# Check for debugging statements
if grep -r "console.log\|debugger\|TODO" --include="*.js" .; then
echo "⚠️ Debugging statements found!"
exit 1
fi
```
## Automatic Branch Naming
```bash
alias feature='git checkout -b feature/$(date +%Y%m%d)-$1'
```
Now `feature "user-auth"` creates `feature/20240122-user-auth`.
## The Commit Message Template
```
[TYPE] Brief description
Why:
- Context for this change
What:
- Specific changes made
Testing:
- How to verify it works
```
## The Weekly Cleanup Script
Deletes merged branches, prunes remotes, and garbage collects. Keeps the repo clean and fast.
## ROI
These automations save ~5 hours per week and countless prevented mistakes. The time invested in setting them up paid back in days.

View file

@ -1,41 +0,0 @@
---
title: "Academic Writing with Obsidian and Pandoc"
description: "A complete workflow for academic papers - from notes to publication-ready PDFs."
pubDate: "Feb 12 2024"
image: "https://images.unsplash.com/photo-1456324504439-367cee3b3c32?w=400&auto=format&fit=crop&q=60"
authorImage: "/avatar/avatar1.png"
authorName: "Neeldhara"
---
# Academic Writing with Obsidian and Pandoc
Transform your scattered research notes into beautiful academic papers with this workflow.
## The Setup
- **Obsidian**: For note-taking and knowledge management
- **Pandoc**: For document conversion
- **LaTeX**: For typesetting
- **Zotero**: For reference management
## The Magic Command
```bash
pandoc paper.md \
--filter pandoc-citeproc \
--bibliography=refs.bib \
--template=academic.tex \
-o paper.pdf
```
## Templates for Everything
From conference submissions to journal articles, templates ensure consistency and save time.
## Version Control Integration
Git + Obsidian = perfect history of your thinking process.
## The Result
From messy notes to camera-ready PDF in minutes, not hours.

View file

@ -1,31 +0,0 @@
---
title: "Understanding the Latest Approximation Algorithm for Set Cover"
description: "A detailed walkthrough of a breakthrough approximation algorithm with practical implications."
pubDate: "Feb 15 2024"
image: "https://images.unsplash.com/photo-1516321318423-f06f85e504b3?w=400&auto=format&fit=crop&q=60"
authorImage: "/avatar/avatar1.png"
authorName: "Neeldhara"
---
# Understanding the Latest Approximation Algorithm for Set Cover
A recent paper achieves a breakthrough in the Set Cover problem, improving the approximation ratio while maintaining practical runtime.
## The Algorithm
The approach combines local search with a clever LP rounding scheme. The dual interpretation provides beautiful geometric insights.
## Why This Matters
Set Cover appears everywhere - from facility location to machine learning feature selection. This improvement has immediate practical impact.
## Implementation Details
The paper's theoretical elegance translates surprisingly well to practice. Key optimizations include:
- Lazy evaluation of set intersections
- Incremental updates to the LP solution
- Smart caching strategies
## Future Work
The techniques here might extend to weighted variants and online settings.

View file

@ -1,31 +0,0 @@
---
title: "Deep Dive: A New Approach to Graph Decomposition"
description: "An in-depth analysis of a recent paper on hierarchical graph decomposition and its implications."
pubDate: "Jan 20 2024"
image: "https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=400&auto=format&fit=crop&q=60"
authorImage: "/avatar/avatar1.png"
authorName: "Neeldhara"
---
# Deep Dive: A New Approach to Graph Decomposition
This paper introduces a novel framework for decomposing graphs into hierarchical structures that preserve important properties while enabling efficient algorithms.
## The Main Result
The authors prove that every graph with treewidth k can be decomposed into a tree of bags where each bag has size at most k+1. While this sounds like the definition of tree decomposition, the clever twist is in how they construct it.
## Technical Innovation
The key insight is using a charging scheme that amortizes the cost of decomposition across multiple levels. This leads to an O(n log n) algorithm, improving on the previous O(n²) bound.
## Implications
This work opens new avenues for:
- Parallel algorithms on bounded treewidth graphs
- Approximation algorithms for NP-hard problems
- Dynamic programming optimizations
## Open Questions
The paper leaves several intriguing questions open, particularly about the optimality of their charging scheme.

View file

@ -1,26 +0,0 @@
---
title: "Quantum Computing Meets Classical Algorithms"
description: "Exploring the intersection of quantum and classical algorithmic techniques from recent conferences."
pubDate: "Mar 10 2024"
image: "https://images.unsplash.com/photo-1635070041078-e363dbe005cb?w=400&auto=format&fit=crop&q=60"
authorImage: "/avatar/avatar1.png"
authorName: "Neeldhara"
---
# Quantum Computing Meets Classical Algorithms
Recent conferences have showcased fascinating connections between quantum and classical computing paradigms.
## Quantum Speedups for Graph Problems
### Quantum Walks on Graphs
New quantum algorithms achieve quadratic speedups for certain graph traversal problems. The techniques combine amplitude amplification with clever graph representations.
## Classical Simulation of Quantum Algorithms
Surprisingly, several "quantum" algorithms have inspired better classical algorithms. This cross-pollination has led to improvements in both fields.
## The Future is Hybrid
The most practical near-term applications combine quantum and classical processing, leveraging the strengths of each paradigm.

View file

@ -1,32 +0,0 @@
---
title: "ZSA Moonlander: Ergonomic Keyboard for Coders"
description: "Six months with a split ergonomic mechanical keyboard - the good, the bad, and the RSI relief."
pubDate: "Feb 20 2024"
image: "https://images.unsplash.com/photo-1587829741301-dc798b83add3?w=400&auto=format&fit=crop&q=60"
authorImage: "/avatar/avatar1.png"
authorName: "Neeldhara"
---
# ZSA Moonlander: Ergonomic Keyboard for Coders
After years of wrist pain, I took the plunge into ergonomic mechanical keyboards.
## The Learning Curve
Week 1: 20 WPM and questioning life choices
Week 2: 40 WPM and seeing the light
Month 2: Back to 80 WPM with no wrist pain
## The Good
- Columnar layout makes sense once muscle memory adapts
- Thumb clusters are game-changers for shortcuts
- The configurability is endless (perhaps too endless)
## The Investment
At $365, it's expensive. But compared to physical therapy or career-limiting injury? Bargain.
## Who Should Buy This?
If you type for a living and feel any discomfort, don't wait. Your future self will thank you.

View file

@ -1,35 +0,0 @@
---
title: "Obsidian: A Year Later"
description: "Reflections on using Obsidian for research notes, teaching materials, and personal knowledge management."
pubDate: "Jan 15 2024"
image: "https://images.unsplash.com/photo-1484480974693-6ca0a78fb36b?w=400&auto=format&fit=crop&q=60"
authorImage: "/avatar/avatar1.png"
authorName: "Neeldhara"
---
# Obsidian: A Year Later
After a year of daily use, Obsidian has transformed how I think about knowledge management.
## What Works Brilliantly
### The Graph View
Seeing connections between ideas visually has led to unexpected research insights. The graph isn't just pretty - it's functional.
### Plugin Ecosystem
The community plugins are incredible. Dataview turns your notes into a database. Templater automates repetitive tasks.
### Local Storage
Your notes are just markdown files. No vendor lock-in, complete control, and peace of mind.
## Pain Points
### Mobile Experience
While functional, the mobile app lacks the fluidity of the desktop version. Syncing can occasionally hiccup.
### Learning Curve
The flexibility means complexity. New users might feel overwhelmed by options.
## The Verdict
For academics and researchers, Obsidian is transformative. The investment in learning pays dividends in productivity and insight.

View file

@ -1,31 +0,0 @@
---
title: "Creating Art with Claude: A Collaborative Journey"
description: "Exploring creative possibilities through conversations with AI - from generative art to interactive poetry."
pubDate: "Jan 18 2024"
image: "https://images.unsplash.com/photo-1558591710-4b4a1ae0f04d?w=400&auto=format&fit=crop&q=60"
authorImage: "/avatar/avatar1.png"
authorName: "Neeldhara"
---
# Creating Art with Claude: A Collaborative Journey
What happens when you treat AI as a creative collaborator rather than just a tool?
## The Experiment
I asked Claude to help design a generative art algorithm based on mathematical fractals. The conversation evolved into something unexpected.
## The Process
**Me**: "Let's create something beautiful with math."
**Claude**: "How about we visualize the Collatz conjecture as a tree?"
What followed was a two-hour deep dive into number theory, aesthetics, and the nature of creativity itself.
## The Result
Not just code, but a philosophical exploration of pattern, meaning, and the intersection of human and artificial creativity.
## Reflection
AI doesn't replace human creativity - it amplifies it in unexpected directions. The key is approaching it as a dialogue, not a command.

View file

@ -1,28 +0,0 @@
---
title: "Philosophical Dialogues with LLMs: On Consciousness and Computation"
description: "Deep conversations with AI about the nature of consciousness, free will, and what it means to understand."
pubDate: "Feb 28 2024"
image: "https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=400&auto=format&fit=crop&q=60"
authorImage: "/avatar/avatar1.png"
authorName: "Neeldhara"
---
# Philosophical Dialogues with LLMs: On Consciousness and Computation
Can a sufficiently complex computation be conscious? I asked an AI, and the conversation surprised me.
## The Question
"Do you experience anything when you process text, or is it just computation?"
## The Response That Made Me Think
The AI didn't claim consciousness, but asked: "What's the difference between your neurons firing and my weights activating? Both are physical processes. Where does experience emerge?"
## Going Deeper
We explored qualia, the Chinese Room argument, and integrated information theory. Not to find answers, but to refine questions.
## The Irony
Discussing consciousness with something that might not have it - or might not know if it has it - mirrors our own uncertainty about consciousness itself.

View file

@ -9,7 +9,7 @@ import { SITE_TITLE } from '@/consts';
export async function getStaticPaths() {
const posts = await getCollection(ACTIVE_BLOG_SITE.key);
return posts.map((post) => ({
params: { slug: post.id },
params: { slug: post.id.replace(/\/index$/, '') },
props: post,
}));
}

View file

@ -14,7 +14,7 @@ export async function GET(context) {
site: context.site,
items: posts.map((post) => ({
...post.data,
link: `/${post.id}/`,
link: `/${post.id.replace(/\/index$/, "")}/`,
})),
});
}