Its a learning experience. What I did immediately when getting home was write the damn task to completion to prove I could do it. Mainly what interviewers are wanting you to do in that kind of task is vocalise what you're thinking. It's useful to them since you're showing a logical approach to understanding and breaking down the problem. You show that you're a communicator. It's useful to you since you're talking it aloud and generally this allows you to avoid pitfalls before they happen.
I don't think you're going to completely avoid this kind of task in future interviews, so practice with a friend! Don't get too disheartened - this experience is one that a lot of grad coders will have and now reviewing it and improving is a task that will let you kick ass in future.