File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes combination of non repeating 9 digit numbers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "combination of non repeating 9 digit numbers" Watch "combination of non repeating 9 digit numbers" New topic
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: 4240
    
    7

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: 10916
    
  12

Do you want a combination, or ALL combinations?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
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: 10916
    
  12

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: 36508
    
  16
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: combination of non repeating 9 digit numbers
 
Similar Threads
Unicode
combination generator
Why a legal identifier cannot include the character #
Help me solve a puzzle on datastructures
WA #1.....word association