| Author |
combination of non repeating 9 digit numbers
|
krishna kumar.s
Greenhorn
Joined: Oct 01, 2011
Posts: 19
|
|
|
Can anybody tell me step by step approach to create a combination of numbers using 123456789 . Any link or algorithm would be helpful. I am a begginer in Java your input is highly appreciated.
|
 |
Suryanarayana murthy
Greenhorn
Joined: Mar 25, 2010
Posts: 3
|
|
I am not clear about your question. Please be clear and specific. What do you want to do with the numbers. What is the output you are expecting
Thanks & Regards
Surya
|
 |
Wesleigh Pieters
Ranch Hand
Joined: Sep 04, 2012
Posts: 81
|
|
Suryanarayana murthy wrote:I am not clear about your question. Please be clear and specific. What do you want to do with the numbers. What is the output you are expecting
Thanks & Regards
Surya
ditto
|
 |
krishna kumar.s
Greenhorn
Joined: Oct 01, 2011
Posts: 19
|
|
|
I want to create combination of 9 digit numbers using 9 numbers . for example 123456789,213456789, 312456789 etc . To solve a puzzle I need them. numbers should not repeat.
|
 |
Wesleigh Pieters
Ranch Hand
Joined: Sep 04, 2012
Posts: 81
|
|
there might be an easier way to do it with just a normal array but this works:
I just created an arraylist of Integers, added the numbers 1-9 into it and then used the Collections shuffle method on it.
edit, sorry you want it to be one number made out of that?
if so this works, not very tidy but yeah I am newish to JAVA and programming.
|
 |
Ivan Franko
Ranch Hand
Joined: May 30, 2011
Posts: 44
|
|
but this is 9! results. (9*8*7*6*5*4*3*2=362880)
Is it ok?
|
 |
Wesleigh Pieters
Ranch Hand
Joined: Sep 04, 2012
Posts: 81
|
|
|
so confused by that post now O_o
|
 |
Matthew Brown
Bartender
Joined: Apr 06, 2010
Posts: 3860
|
|
|
I'd go with Wesleigh's approach of using Collections.shuffle(). Simple, and as random as you're going to realistically get.
|
 |
fred rosenberger
lowercase baba
Bartender
Joined: Oct 02, 2003
Posts: 10040
|
|
|
Do you want a combination, or ALL combinations?
|
Never ascribe to malice that which can be adequately explained by stupidity.
|
 |
krishna kumar.s
Greenhorn
Joined: Oct 01, 2011
Posts: 19
|
|
|
I want all possible combinations of 9 digit numbers which uses only 123456789 with a condition same number should not repeat.
|
 |
fred rosenberger
lowercase baba
Bartender
Joined: Oct 02, 2003
Posts: 10040
|
|
Ok. The first thing that you need to do is FORGET about java, computers, data structures, methods, etc.
suppose someone gave you 9 tiles, each with a single digit on it.
How would you go about arranging them so that you would know for a fact that when you are done, you have gotten to every possible arrangement?
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32830
|
|
|
362880 is not that many for a computer to store. But whoever said that is correct; that is how many numbers there are with 9 digits all different.
|
 |
 |
|
|
subject: combination of non repeating 9 digit numbers
|
|
|