You can usually tell the difference between being stuck on something because you fundamentally don't get it, and being stuck on something because while you do get it, you don't see the next step forward. This is called a vision problem.
After you notice you have a vision problem, you should usually disengage and find help for the one step you can't see yourself right now. Don't waste resources thinking deeply down lines of thought that you already suspect won't help.
Vision problems sketched out
Picture the following: You're taking a timed test in a mathematics course, where you have no recourse to outside materials. It's just you and your brain, and whatever you two brought to the table, versus the problem. And when you look at it, you get that weird, cognitive dissonance of: This is easy. I don't know how to solve this.
This happens quite frequently to me, often enough that I have a term for it on its own. I call it a "vision problem". Here's one test: Is it a problem where a 2-second glance at the answer key tells you all you need to know to solve it yourself? Then that's probably a vision problem, my friend.
Having vision problems is actually a really good sign in one sense. While a test (or test-grader) might not appreciate it, especially if your vision problem concerns the "set-up" step for the problem (sadly the most common in my experience), you having confidence that if only you set it up correctly, the rest would flow without much difficulty, is a sign that you've acquired some conscious competence over a good chunk of the terrain.
Vision problems are kind of like a funhouse mirror version of guessing the teacher's password. Guessing the password implies that you've learned to recite an incantation that lets you pretend you're comfortable with all the steps. With a vision problem, however, you really do feel comfortable with almost all of the steps already; your neural network just isn't lighting up that one crucial connection you need to make it all fit together. A small incantation might just do the trick, but you don't know what it is. And because that neural connection does reliably light up in the teacher's network, it might be difficult for the teacher to wrap their head around where exactly you are stuck, or to understand how what was to them an offhand remark suddenly let you figure out the whole problem. (Having worked for several years as a math and physics tutor to very lovely people with lower-than-average IQs, I like to tell myself I have a sense for this by now.)
If you really want to get abstract with it, you can imagine your teacher as a random process which generates "teacher-shaped problems", and yourself as a random process which generates "you-shaped solutions"; when you can reliably pattern match the correct you-shaped solution to a random teacher-shaped problem, congrats! You've achieved mastery of the material, insofar as most people care to look. That lends a broader view to the idea of "vision problems" -- you are genuinely training your ability to see the easiest path forward for a given style of problems.
How to fix a vision problem
Enough crude etiology. What do we do to fix a vision problem?
Well, the obvious first step is to recognize you're having one in the first place. That's why I mentioned the "answer key" thing above; for me, at least, that proves to be a really good bellwether.
The next step is to decide: Do I have the time, resources, and motivation to pursue fixing this on my own? Or would I be better served to find a different source of insight? There are pros and cons to each, but cards on the table here -- I'm heavily biased towards the latter.
While sitting around for hours quietly contemplating the true form of whatever you're working with until you have a breakthrough insight makes my weird intellectual purity norms squee in delight, it's ... not actually a terribly efficient way to do things. Heck, one of the reasons people really appreciate multiple good code examples in documentation is because it saves them the effort of actually mentally reconstructing what this or that function or method is supposed to do by reading the documentation underneath.
Also, to be honest, more often than not I find that when I do try that, I don't actually get that sudden new perspective I'm looking for. I just brute force my way through the vision problem with whatever tools I currently have at my disposal, sometimes (often) reinventing wheels to get me to where I need to go. This is often followed by a sense of remorse when I see my classmates, who paid a little more attention to how the teacher and the book does things, solve a problem in minutes which took me hours, just because they remembered the little thing that actually helps them.
Oh, speaking of memory --
Memory is not sexy in mathematics.
“Rote memorization” is the most degrading slur you can fling at a math class. “Reciter of digits of pi” is the most awful caricature of mathematicians in the public eye. In grad school, the cardinal sin is to read a paper with a focus on memorizing names and results: we are bombarded with exhortations like if you learned the Arzelà-Ascoli theorem deeply, it would be impossible to forget. Apparently, if you really understand mathematics, everything (down to the accents on the names of 19th century Italian mathematicians) would be so natural as to render rote memorization completely unnecessary.
All these attitudes can be quite detrimental to the young mathematician who, at the end of the day, needs to memorize an enormous amount of arbitrary data in order to get up to speed in their field. [...] Memory, especially short-term working memory, is perhaps the scarcest resource in mathematical work.
That's a quote from the blog of one Xiaoyu He, a mathematics grad student at Stanford who has ... quite a pedigree of mathematical talent. So I have at least n=1 data points of actually good mathematicians on my side.
I bring that up because the third step is to actually grok and solve the vision problem (can't help much there, fitting someone else's understating into your own brain is idiosyncratic AF), and then the fourth step is to set up memory-systems so you actually integrate the new vision into your old self.
The maddening thing about vision problems is that, more often than not, they are slippery. They're the kinds of problems where you follow along with the teacher's example without a hitch, then get distracted by the vicissitudes of life for a few hours, and then once you're at home, it's... Gone. Poof. Excommunicado. Did you take notes on that part? I hope you did; then you might be able to find the vision you currently lack. But what about after you solve the problem it's used for, and you walk away from it for a couple of days? It'll probably disappear again. You've solved the problem, but you haven't improved your chances much of being able to solve the problem again; you need to practice your newfound vision.
The ideal scenario is probably to use Anki or Mnemosyne, but as an SRS junkie, I'm a little biased. 😉