How should values be arranged?
Move from an intuitive goal—“even spacing”—to a concrete list of binary values.
Interactive CS mini-lesson · 8–10 minutes
Learn the pattern. Predict the beats. Reveal the algorithm.
Musicians distribute sound through time. Programmers distribute values through a sequence. In this lab, those are the same problem.
Start the first challengeRepeat one rule across a sequence.
Wrap positions around a cycle.
Turn “evenly spaced” into steps.
Predict before the computer answers
Classify every position as a beat or a rest. Each press cycles from unknown to beat to rest. Only then can you reveal the pattern.
Challenge 1 of 3
Place 3 beats across 8 steps so the gaps feel as even as possible.
0 of 8 steps classified
The computer’s sequence
Model a beat as 1 and a rest as 0.
Repeatedly group beats with rests until the gaps are balanced.
Shift the list with modulo logic while preserving its structure.
def euclidean_rhythm(steps, pulses, rotation=0):
steps = max(4, min(16, round(steps)))
pulses = max(1, min(steps, round(pulses)))
rotation = rotation % steps
if pulses == steps:
pattern = [1] * steps
else:
counts, remainders = [], [pulses]
divisor = steps - pulses
while remainders[-1] > 1:
counts.append(divisor // remainders[-1])
remainders.append(divisor % remainders[-1])
divisor = remainders[-2]
counts.append(divisor)
pattern = []
def build(level):
if level == -1:
pattern.append(0)
elif level == -2:
pattern.append(1)
else:
for _ in range(counts[level]):
build(level - 1)
if remainders[level] != 0:
build(level - 2)
build(len(counts) - 1)
first_beat = pattern.index(1)
pattern = pattern[first_beat:] + pattern[:first_beat]
return [
pattern[(index - rotation) % len(pattern)]
for index in range(len(pattern))
]Transfer the idea
Move from an intuitive goal—“even spacing”—to a concrete list of binary values.
The list length and beat count never change, even when the starting point rotates.
Count, group, compare gaps, repeat, and rotate: each step can be tested on its own.
For the Brilliant team
Created as a new application demonstration, this prototype shows how I would translate an abstract CS idea into an approachable, interactive problem-solving journey.
Learners commit to a model first, so the reveal produces useful feedback instead of passive recognition.
Musical beats make distribution visible and audible before the Python representation appears.
Each challenge foregrounds a new idea—distribution, density, then rotation—supporting comparison and transfer.
Grid, sound, binary sequence, prose, and code give learners several ways into the same concept.