Connor Hyatt

← writing

Forty-three quintillion

The first time I picked up a Rubik's Cube, I was a toddler at my grandma's house, and I couldn't finish a single side.

That is the right first reaction. A cube has about 43 quintillion possible states. Nobody twists their way to a solution, no matter how long they try. The people who solve one in seconds aren't searching that space. They are recognizing where they are in it.

I spent a decade getting good at that before I ever opened LeetCode. When I finally did, it felt familiar.

Nobody memorizes solutions

Speedcubers don't memorize solutions. They memorize situations. You look at the cube, recognize the case in front of you, and run the sequence of moves that handles it. These are three cases from the last layer:

The Sune case
SuneR U R' U R U2 R'
The Pi case
PiR U2 R2 U' R2 U' R2 U2 R
The Headlights case
HeadlightsR2 D R' U2 R D' R' U2 R'

A new coding problem works the same way. At first glance it looks like nothing you have seen. Look again and it is usually a pattern you know: two pointers, a sliding window, dynamic programming. The skill isn't knowing every answer. It is naming the problem quickly and reaching for the approach that fits.

Your hands learn before you do

After enough repetition, a cuber's fingers start an algorithm before they have consciously decided to. Recognition and execution become one motion.

Programming has its own version. Write enough binary searches and you stop thinking about the boundaries. The common patterns end up in your hands, and your attention is free for the part of the problem that is actually new. Both come from the same place: drilling patterns until recognizing them is instant.

Solving is only the start

Getting a cube solved is the beginning. The real work is solving it in fewer moves, then fewer still. Code is the same. A working answer is a first draft. The finished version uses less time and less memory, and reads like it couldn't have been written any other way.

That is the standard I carry into everything I build. Working is where you start, not where you stop.

If you want to start

For the cube, learn the beginner's method, then move to CFOP, which splits a solve into four stages: the cross, the first two layers, orienting the last layer and permuting it. Time every solve.

For LeetCode, start with easy problems and spend more time reading strong solutions than writing your own. Learn one pattern at a time. I try to solve one new problem a day.

Both start out impossible. Neither stays that way.

more writing

all writing