FlyWire connectome · spiking simulation · Polish Olympiad in Informatics
Can a fruit fly brain solve an olympiad problem?
I simulated the complete wiring diagram of an adult fruit fly brain, all 138,639 neurons and 15.1 million connections traced from electron microscope images by the FlyWire project, and gave it task TES from the XVII Polish Olympiad in Informatics. This page shows how the test was built, run and graded, one step at a time.
Not in this model: it answered at coin-flip level. Why it failed, and what it takes to give a fly a fair chance, is the interesting part.

1 · The puzzle
Can b be made by crossing numbers out of a?
Task TES, "Test na inteligencję", XVII Polish Olympiad in Informatics, stage I. Sequence a holds up to 1,000,000 numbers, and every query b must be answered TAK (yes) or NIE (no).
| a | query b | answer | why |
|---|---|---|---|
| 1 5 4 5 7 8 6 | 1 5 5 8 6 | TAK | every number found, in order |
| 1 5 4 5 7 8 6 | 2 2 2 | NIE | there is no 2 in a |
| 1 5 4 5 7 8 6 | 5 7 8 | TAK | 5, then 7, then 8 |
| 1 5 4 5 7 8 6 | 1 5 7 4 | NIE | all numbers exist, but the 4 comes too early |
The classic solution stores, for every value, the sorted positions where it appears in a. It then walks through b and binary-searches the earliest position after the previous match; if a number has none left, the answer is NIE. All queries together take O((m + total length of b) log m), and solution/tes.py passes all 25 official tests. Step through it:
Try the algorithm
positions of each value in a
steps
2 · Method
How a fly takes the test, step by step
A whole-brain simulation cannot read digits, so the puzzle is played to it as smells, and a readout is trained to pull the answer out of its spikes. The brain itself is never trained.
- Puzzlea = 1 5 4 5 7 8 6
b = 5 7 8 - Smellsone 50 ms smell per number
- Receptorsrandom spikes in the matching smell neurons
- Fly brain138,639 spiking neurons, FlyWire wiring
- Spike countsper neuron, per 75 ms
- Readoutlinear, the only trained part
- TAK / NIE
-
Load the wiring
FlyWire release 783 lists which neuron connects to which, through how many synapses, and whether the sender excites or inhibits (predicted from its neurotransmitter). I use the processed connectivity of Shiu et al. 2024 and FlyWire's cell annotations to find smell receptors, mushroom body cells and the neurons that drive the body.
138,639neurons15,091,983connections53smell receptor types5,177Kenyon cells, the learning centre -
Make every neuron a leaky integrate-and-fire unit
The same equations and constants as the published whole-brain model. A neuron spikes when its voltage passes -45 mV, resets to -52 mV and rests for 2.2 ms. Each spike of neuron \(j\) adds \(w_{ij} = 0.275\,\text{mV} \times n_{ij} \times s_j\) to neuron \(i\) after 1.8 ms, for \(n_{ij}\) synapses with sign \(s_j = \pm 1\).
\[ \tau_m \frac{dv}{dt} = v_0 - v + g, \qquad \tau_s \frac{dg}{dt} = -g, \qquad \tau_m = 20\text{ ms},\; \tau_s = 5\text{ ms} \]The linear part is integrated exactly over each 0.1 ms step, so there is no numerical drift:
\[ u(t+\Delta t) = u(t)\,e^{-\Delta t/\tau_m} + g(t)\,\frac{\tau_s}{\tau_s - \tau_m}\left(e^{-\Delta t/\tau_s} - e^{-\Delta t/\tau_m}\right), \qquad u = v - v_0 \]Checked against the published modelIts headline result is that sugar-sensing neurons drive MN9, the motor neuron that extends the proboscis to feed. This implementation reproduces it: MN9 fires at 71.5 Hz with sugar input and stays silent without.
-
Turn numbers into smells
Each number drives one type of olfactory receptor neuron with random (Poisson) spikes for 50 ms, one number per 75 ms slot: first b, a pause, then a, then a silent slot.

-
Simulate only what can fire, and prove nothing changes
A neuron that never spikes cannot influence anything. A pilot on the full brain finds every neuron that spikes or comes within 3 mV of threshold; the experiment runs on that subnetwork. Fresh trials on the full and trimmed brain, with identical random input, must give identical spikes. Trials run side by side as (neurons x trials) arrays, and every condition gets the same random seeds, so the brain and its controls smell exactly the same thing.

-
Read the answer out
A linear classifier reads the log spike count of every neuron in every 75 ms slot, about 140,000 features, and says TAK or NIE. That is the most generous question you can ask: is the answer present in the activity at all? The response matrix had 450 million nonzero entries, so the classifier is fitted exactly on the trial-by-trial kernel instead:
\[ \hat t(x) = k(x)^\top \left(K + \lambda I\right)^{-1} t, \qquad K_{ij} = x_i^\top x_j \;\;(3{,}180 \times 3{,}180) \] -
Grade it without fooling yourself
Generated puzzlesrandom TES instances, official queries excluded- train fits the readout
- validation picks settings
- test gives the reported number
Official examthe 12 official test queries small enough to smell, never used for training- each played 15 times, since the brain is noisy
- the majority vote is the answer
- Always answer TAKno computation at all
- Raw smells, no brainthe same readout on a perfect record of the smells
- Randomly rewired brainsame neurons, connection counts and signs, wiring shuffled
- Trained artificial networkan upper reference that is not a fly
3 · Round 1 results
At coin-flip level, and worse than its own input
Correct answers on 600 held-out puzzles. Hover a bar for its score on the hardest kind of puzzle, where every number is present but the order is wrong, and on the official exam.

The brain loses information
Its activity is harder to read (52.8%) than the smell signal going into it (61.8%). Processing made the answer less visible, not more.
The real wiring didn't help
The same brain with its connections randomly shuffled scored 55.0%. The fly's actual wiring gave no advantage on this task.
Nothing reaches the body
The descending neurons, which carry commands to the body, are at chance (48.3%).
It keeps nothing
75 ms after the last smell the activity is uninformative (49.7%), yet the task needs a whole sequence held in mind.
4 · Inside the brain
Why it failed: the brain floods, and forgets
The same puzzle played to two brains. In round 1 almost every sampled neuron fires almost all the time, whichever number is smelled: 874,511 spikes in one puzzle. With short-term memory (round 2) activity is sparse and tied to the smells: 12,503 spikes.


No memory. In the published model activity fades within tens of milliseconds. TES needs all of a remembered while b is checked.
Flooding. The uniform synaptic strength that makes the model's taste pathway work saturates the smell pathway. At round 1's 150 Hz, about 70% of all neuron-and-time-slot pairs contain spikes.
5 · Round 2
A fairer rerun: let neurons tire, calibrate the smells, climb a ladder of tasks
Every setting below was fixed before any task was run, and every rule that was tried and dropped is recorded in the repository.
-
Short-term memory
Two textbook mechanisms real neurons have, added on top of the published model: spike-frequency adaptation (a neuron that fires a lot fires less for a while) and short-term synaptic depression (a synapse used a lot delivers less for a while).
\[ \tau_m \frac{dv}{dt} = v_0 - v + g - a, \qquad \tau_a \frac{da}{dt} = -a, \qquad a \leftarrow a + b \;\text{ at every spike} \]\[ \text{a spike of } j \text{ delivers } w_{ij}\,x_j,\;\text{ then } x_j \leftarrow (1-U)\,x_j, \qquad \tau_{rec}\frac{dx_j}{dt} = 1 - x_j \]preset adaptation b τa depression U τrec mild 0.1 mV 200 ms 0.05 300 ms strong 0.5 mV 800 ms 0.2 1000 ms -
Realistic smells at a calibrated strength
Every number now activates a blend of three receptor types, like a real odor. The strength is chosen per memory setting by what every task needs first: naming the number being smelled right now, in the middle of a stream of smells.

memory strength smells named Kenyon cells active none 3 Hz 30% 38.5% mild 40 Hz 56% 14.1% strong 40 Hz 89% 3.0% -
A ladder of tasks instead of one pass or fail
Same or different? Was it in the list? Which came first? Then full TES, each with train, validation and test sets and 95% confidence intervals. A trained network learns the first three almost perfectly; simply adding up the smells cannot.
StatusCalibration, trimming for strong memory (identical spikes: 44,540 on both brains) and every baseline are done and committed. The full ladder under every condition is an unattended, resumable pipeline estimated at about 12 hours of CPU, and has not been run to completion.
6 · Engineering
Built to be checked
Batched simulator
Vectorised NumPy and SciPy integrate-and-fire engine with exact exponential integration, a ring buffer for synaptic delays and many trials per process. Reproduces the published MN9 result.
Exact trimming
Only 9.8% of the brain is simulated in round 1, with identical spike trains on held-out trials: 5,284,179 spikes on both brains.
Memory-safe readout
A 5.4 GB response matrix becomes an exact 3,180 x 3,180 kernel, built in chunks, reproducing the direct fit's scores exactly.
Measured, not assumed
A C sparse-matrix propagation matched np.add.at (per-neuron correlation 0.9995) but ran at 0.9x the speed, so it was dropped.
Honest evaluation
Official queries excluded from training data, untouched test sets, a control for every claim, and every dropped calibration rule recorded.
Tested
18 unit tests: the greedy check against brute force, the official solution, the simulator on hand-built networks including trimming exactness, and the readout kernel.
7 · Limitations
What this does not show
- One simple neuron model everywhere. No gap junctions, neuromodulators, learning or graded (non-spiking) neurons, and transmitter signs are predictions. This is the fly's exact wiring running on generic neurons.
- The readout is external. It asks whether the answer is linearly present in the activity, not whether a fly would act on it.
- The encoding is a choice. One smell per number, 75 ms per smell; a real fly would first have to be trained to treat smells as symbols.
- Tiny inputs only. Of the 25 official tests, only 12 queries are small enough to smell; the rest hold up to 1,000,000 numbers, about 21 hours of continuous smelling each.
- Round 2 is unfinished. The fairer design is built, calibrated and tested, but its full ladder has not been run.
Data and credits
- FlyWire Consortium; Dorkenwald, S. et al. Neuronal wiring diagram of an adult brain. Nature 634 (2024).
- Schlegel, P. et al. Whole-brain annotation and multi-connectome cell typing of Drosophila. Nature 634 (2024).
- Shiu, P. K. et al. A Drosophila computational brain model reveals sensorimotor processing. Nature 634 (2024).
- Task TES, Test na inteligencję, XVII Polish Olympiad in Informatics, stage I (2009).