simple string permutation coding problem