Digit combinations

closed account (4Gv4jE8b)
Hi, I decided to learn C++ not too long ago, but I've hit a stump in a practice question that I have no idea how to solve.
The problem is:
Given a collection of 3 different digits, each ranging from 0 - 8, implement a program that finds all unique numbers that can be formed using the 3 digits assuming that 6's can be inverted to form 9's.
E.g. from the 3 digits 0 3 6, it is possible to create the following combinations:
0, 3, 6, 9, 30, 36, 39, 60, 63, 90, 93, 306, 309, 360, 390, 603, 630,
903, 930.
Note that a digit can only be used once in the sequence (this includes the inverse).

Any help would be greatly appreciated.
My blog shows you how to use permutations. exactly what you're talking about (use stringstream):

http://ultifinitus.blogspot.com/2011/04/string-permutation.html
closed account (4Gv4jE8b)
I forgot to mention that I'd rather not use arrays or functions at all, and seeing as it hasn't been covered in great detail yet, I'd assume that there would be a way to do it without strings as well.

Again, any help would be greatly appreciated.
Last edited on
Topic archived. No new replies allowed.