There are many solutions. If you know about recursion, the easiest solution uses this technique. Otherwise, consider using an array or vector to hold solutions. If this still seems to hard, then consider using six nested loops (but avoid repeating characters and make sure you allow for all string lengths).