"If you can't solve a problem in 15 minutes, ask for help."
I have been stuck with many bugs when writing code and I would end up spending an hour or even half a day stuck on a small bug that would hold up all progress. Most bugs could be solved within minutes just by asking someone for help. I work on a team with a lot of new developers who are not familiar with the quirks of the frameworks used on the project, so I always try to encourage them to ask for help. They often tell me, "I didn't want to bother you," but NO, I would rather you bother me instead of letting you spend half a day fixing a bug that I can fix in a minute or tell you who would know the solution.
While I say this, I am also guilty of holding back on questions, especially when I know who to ask. Maybe it's pride, but software development is about efficiency, especially for the whole team.
If you have the opportunity to bring on new software developer to a team, give them this rule. You might be breaking your focus every so often, but you would likely be saving someone from wasting a whole morning fixing that "damned bug."