You used your own brain to figure out what that output should be. How did you do it in your head?

I am 100% serious in saying you should write down the steps you used in your head. make them simple and clear. When you've done that, go back and refine them to be more specific. You can't say "I counted the number of times bbb occurred", because I would come back with "How did you know to count 'bbb'? Once you knew you needed to count those, how did you count them?"

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors