redone part of codeeval in C
fix perm