Is there a problem reference? or a link?
So what have you got so far? Show us the code.
I can’t find any problem with your output for the problem as you describe it, so perhaps your interpretation of what the problem is asking for is wrong somewhere?