11-08-2009 01:46 PM
11-08-2009 02:05 PM
Hi jeshu,
this really sounds like homework. I think I saw that question before...
We will not do your homework here, but we will be happy to help for specific questions. So show what you have done before & tell where you have problems!
11-08-2009 02:21 PM
11-08-2009 02:32 PM
Hi jeshu,
in the string palette you find a function to convert a string into an U8 array.
For the theory you may start here!
Good luck for tomorrow's test - I will now enjoy my Sunday evening
11-08-2009 03:17 PM
11-08-2009 09:18 PM
Hi jeshu
This is not a difficult code to make. I have already done this.
Start like this. I hope you are familiar with the for loop!
So use 4 nested for loops to compare the individulal letters and finally write them in an array. Like you have ABCD. Take A from the first loop and use it to compare with all letters in 2nd loop. As soon as you get different letters in 2nd loop (like A and B), compare these 2 letters with all letters in loop number 3. when you get all 3 different letters from loop number 3 (like A , B , C), compare all the 3 with letters in the final loop. Finally , when you have all three different letters, write them in an array.
11-09-2009 03:32 AM - edited 11-09-2009 03:33 AM
Hi jeshu,
one more hint:
Try to adapt an recursive way of generating combinations:
1) start with 1 char -> one possibility (A)
2) add 2nd char and "insert" it before and after first char -> two additional possibilities (AB, BA)
3) add 3rd char and insert it in every possible position in each of the strings generated before -> 6 more possibilities (CAB, ACB, ABC, CBA, BCA, BAC)
4) add 4th char and repeat step 3 (DCAB, ADCB, ABCD, some more...)
5) do step 3 for all additional chars
This should be a nice exercise to learn how to use for loops, shift registers, building arrays and string functions
11-09-2009 03:38 AM
Ya, this is another way of doing it.
In the method of nested for loops, you can get 24 combinations only if all the letters in the string are different (because of comparison)
But in this method, of insertion, you can get the combinations even if the letters are same in a given string.