🌞 I Keep Losing My Focus — Until I Guard One Window at a Time

Ancient mountain courtyard in golden hour light, with a single bright sunbeam sliding across the stone floor as Arjun and Guru Bodhi watch
The Shifting Sunbeam Court — where a moving band of light becomes Arjun’s first lesson in managing limited attention with a sliding window.
I Want the Best Choice — But I Can’t Compare Everything I Keep Losing the Light — Until I Guard One Window at a Time
Gurukul Tale VI

A story of drifting focus and stolen afternoons — where a moving sunbeam in a temple courtyard becomes our first lesson in the Sliding Window pattern.

Characters: Arjun, Guru Bodhi · Arc: Beginner · Pattern: Sliding Window (Fixed & Variable Size)

📜 Sutra of Fading Light — Too Many Rituals, Not Enough Sun

The Shifting Sunbeam Court lay high in the Gurukul, its stone floor warmed by a single band of morning light. Every day the beam slid slowly across the courtyard, then vanished over the far wall.

Arjun had been given a simple task: perform a sequence of offerings — incense, lamps, water, flowers — only inside the light. Outside the sunbeam, the ritual “did not count”.

This would have been easy, except for one problem: there were too many rituals and only a small moving patch of time and space where they would be “valid”.

Arjun tried to scatter his focus. A lamp here, a chant there, a rushed bow in between. By the time he finished one corner, the light had already moved on.

Arjun: “The sun keeps running ahead of me. I do a little of everything… and finish nothing.”
Young disciple Arjun standing in a temple courtyard as a narrow beam of sunlight moves away from his unfinished offerings
Arjun chases the light across the court — trying to do everything at once, finishing nothing fully.

📜 Sutra of Distraction — The Real-World Version

If this feels uncomfortably familiar, good. Arjun’s courtyard is just your calendar with nicer lighting.

You have a fixed block of energy — maybe 90 minutes of real focus in the morning, another 60 in the evening. Inside those “light windows” your work matters far more than outside.

But you try to cram everything in: email, messages, docs, research, code reviews, deep work. The result?

  • Nothing gets enough attention to actually finish.
  • You feel “busy all day”, but the important work doesn’t move.
  • You end the day like Arjun: tired, annoyed, and behind.
Guru Bodhi standing beside a line of lit lamps that form a glowing window of light along a temple corridor
Guru Bodhi draws a glowing band of lamps — a moving window of attention along a long corridor of tasks.

📜 Sutra of the Moving Window — Guard What the Light Touches

As Arjun panted across the courtyard, the soft thud of a staff echoed against stone.

Guru Bodhi stood at the edge of the light, watching the sun crawl along the floor.

Guru: “You keep chasing the sun, child. Try something else.
Stand still… and guard a window of it.”

He pointed at a rectangular patch of light currently touching four tiles.

Guru: “Imagine the sunbeam is a fixed window that always covers exactly four tiles. You cannot control how fast it moves, but you can control what happens inside that frame.”

“Place your rituals in a row,” he continued, “and wherever the window rests, complete only what lies within. When the sun moves a little, your window moves with it — dropping what fell behind, picking up what just entered.”

This, in algorithm-speak, is the Sliding Window pattern: a moving frame over a sequence, always looking at only a small active subset at a time.

A long temple pathway lit by rows of lamps, with a bright highlighted band moving along the path like a sliding window
A path of lamps where only one glowing band matters at any time — focus as a moving frame, not an explosion in all directions.

🧠 The Beam of Maximum Light — Algorithm Scroll (Fixed Window)

Turn Arjun’s problem into a classic coding puzzle:

You have a row of tiles. On each tile Arjun has placed a lamp of some brightness:
[2, 1, 5, 1, 3, 2]

The sunbeam always covers exactly k consecutive tiles (say, k = 3). Find the maximum total brightness inside the window at any position.

Naïve Approach

Sum every group of k tiles from scratch. For each starting tile i, add up brightness[i : i + k]. Time complexity: O(n · k). Slow if the courtyard is huge.

Sliding Window Insight

When the window moves one step to the right:

  • We drop the value that left the window.
  • We add the new value that just entered.

That means we can update the sum in O(1) time and scan the entire row in O(n).

Python - Max Light in a Sliding Window
from typing import List

def max_light_in_window(brightness: List[int], k: int) -> int:
    """
    Return the maximum total brightness inside any contiguous
    window of size k.
    """

    if k <= 0 or k > len(brightness):
        raise ValueError("k must be between 1 and len(brightness)")

    window_sum = sum(brightness[:k])
    max_sum = window_sum

    # Slide the window one step at a time.
    for right in range(k, len(brightness)):
        left = right - k
        window_sum += brightness[right]      # add entering lamp
        window_sum -= brightness[left]       # remove leaving lamp
        max_sum = max(max_sum, window_sum)

    return max_sum

Complexity

  • Time: O(n) — we touch each lamp at most twice.
  • Space: O(1) — we keep only the current window sum and best answer.

Guru: “Do not recount all the lamps each time you move. Remember what you already know, and update only what changed.”

🧭 Real-World Scroll — Your Day as Sliding Windows

The same pattern shows up in your calendar and habits:

  • Protect a 90-minute deep-work window each morning — only one high-impact task lives there.
  • Use a 30-minute window for messages: clear all inboxes, then let them wait until the window slides back again.
  • For learning, keep a fixed daily study window, sliding it across topics over weeks instead of trying to learn five things at once.
  • On a longer timescale, treat weeks like windows too: each week has a narrow band of attention — guard which projects stand in that light.

The key is this: at any moment, only a small slice of your life can be in true focus. Sliding Window is the discipline of choosing that slice on purpose.

Desk with an open notebook and coffee cup in front of a sunrise window, with sunbeams forming distinct bands of light across the pages
A daily schedule drawn as bands of light on a desk — each beam a focused window of time instead of a blurry, overloaded day.

📜 Sutra of Action — How Arjun Keeps the Light

The next morning, Arjun arranged his offerings in a single row across the courtyard tiles. He chose a window of four tiles — no more, no less.

Wherever the sunbeam fell, he completed only the rituals in that band. When the light moved forward one tile, he let the back tile go and picked up the new one that entered the frame.

By the time the sun climbed over the far wall, every offering had been completed, calmly, inside the light.

Arjun: “I did less at once… and finished more overall.”
Guru: “That is the way of the sliding window. Guard the frame. Let the rest wait their turn.”