← Back to Blog

Article

The Math of Motivation: Implementing Snowball vs. Avalanche Algorithms in React Native

How building TinyDebt taught me that mathematically optimal code often fails the human test - and why I implemented both debt payoff strategies.

Snowball vs Avalanche debt algorithms in React Native

Most developers approach financial apps as a purely mathematical problem: Minimize interest at all costs.

In technical terms, this is the Avalanche Method. You sort a list of debts by interest rate in descending order and allocate surplus cash to the top. Mathematically, it is the most efficient path.

However, when I was building TinyDebt, I realized that code that is "mathematically correct" often fails the "human test." This led me to implement the Snowball Method - sorting by balance size - and the technical implementation taught me a lot about user-centric logic.

The Logic: Sorting for Success

In a local-first React Native environment, handling these calculations without a backend means the client-side logic must be snappy and reliable. Here is a simplified version of the logic I used to allow users to toggle between "Mathematical Efficiency" and "Psychological Momentum."

type Debt = {
  id: string;
  name: string;
  balance: number;
  interestRate: number;
};

// The "Avalanche" Logic: Maximizing Interest Savings
const getAvalancheOrder = (debts: Debt[]) => {
  return [...debts].sort((a, b) => b.interestRate - a.interestRate);
};

// The "Snowball" Logic: Maximizing Psychological Wins
const getSnowballOrder = (debts: Debt[]) => {
  return [...debts].sort((a, b) => a.balance - b.balance);
};

The Technical Challenge: Real-Time Comparison

The real value for the user isn't just seeing a list - it's seeing the impact of their choice. In TinyDebt, I had to build a projection engine that runs both algorithms against the user's monthly "extra" payment to show two different "Debt-Free Dates."

Because the app is local-first (using a simple, privacy-focused data model), these calculations happen instantly. There's no loading spinner while a server calculates the amortization schedule. The result is a UI that feels responsive and encouraging.

Why "Snowball" Wins the UX Battle

While the Avalanche method saves more money in the long run, the Snowball method has a higher "completion rate."

In programming, we call this reducing friction:

  • Avalanche is like refactoring a massive, complex legacy module first. It's the right thing to do, but it's exhausting.
  • Snowball is like fixing three "low-hanging fruit" bugs on Monday morning. It gives you the dopamine hit needed to tackle the big stuff on Tuesday.

Conclusion: Design for Humans, Not Just Databases

When we build tools - especially in the finance space - we have to account for the "human variable." By providing both options in a minimalist, private environment, I found that users stay engaged much longer.

If you're building a utility app, ask yourself: Is my logic optimized for the processor, or for the person using it?