My 9yo and 11yo boys have been dabbling with coding in python, swift, java and html for a couple of years now on and off. Yesterday they decided to participate in their first code jam. They started out, got it set up the way they wanted and left it until today.
This morning turned into nothing but arguing as it didn't come together the way they both wanted it to. The arguing turned into a huge fight(as an aside, as an only child I'm continually impressed by how much and how often brothers can fight, particularly over the smallest of things) and they both ran away crying and screaming at each other. I decided not to intervene and just let it play out.
Well, a couple of hours later I heard them cheering and went to check on them. They were jumping up and down, hugging, and cheering because they finally worked out the code they were stuck on and it was working the way they wanted. They've been glued to the computer working on the rest of their code for hours straight now.
It's not easy to convince kids these days to be resilient, at all, when everything seems to be geared towards instant gratification, but it's so worth it when it works out. However the rest of their project works out it was already a win in my book.