Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!sunybcs!boulder!tramp!baileyc From: baileyc@boulder.Colorado.EDU (BAILEY CHRISTOPHER R) Newsgroups: comp.lang.c Subject: number producing algorithm Message-ID: <19416@boulder.Colorado.EDU> Date: 7 Apr 90 21:34:37 GMT Sender: news@boulder.Colorado.EDU Reply-To: baileyc@tramp.Colorado.EDU (BAILEY CHRISTOPHER R) Distribution: usa Organization: University of Colorado, Boulder Lines: 24 Help! I need an algorithm to generate a series of numbers. This series is of variable length. For example, if I pass a 10 to the function, it needs to generate numbers that have 10 digits. The catch is that the numbers it generates can not have more than one of the same digit, so say, the passed number is 3, it would generate the following: 0 1 2 0 2 1 1 0 2 1 2 0 2 0 1 2 1 0 So, basically, there are n! number of combinations/permutations (whichever it is). Also, I would like it to start with 0 1 2 ... Right now, my function just creates all numbers by counting in the base of the number that is passed (in this case base 3), then it checks to see if there are more than one of the same digit in the number, if so it throws it out. This is being used to create node mappings for multipath graphs. My function is not good because it takes forever when you get up to >6 nodes. Thanks! Chris Bailey :: baileyc@tramp.Colorado.EDU One Agro Mountain Biker - Dialed in for ultra gonzo badness! "No his mind is not for rent, to any god or government" - RUSH Member of Team Buck Naked of Buckingham Palace