This week's book giveaways are in the Jython/Python and Object-Oriented programming forums.
We're giving away four copies each of Machine Learning for Business: Using Amazon SageMaker and Jupyter and Object Design Style Guide and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

combination of non repeating 9 digit numbers

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 3
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but this is 9! results. (9*8*7*6*5*4*3*2=362880)

Is it ok?
 
Wesleigh Pieters
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so confused by that post now O_o
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd go with Wesleigh's approach of using Collections.shuffle(). Simple, and as random as you're going to realistically get.
 
lowercase baba
Posts: 12796
51
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you want a combination, or ALL combinations?
 
krishna kumar.s
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12796
51
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Marshal
Posts: 67527
257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 knew that guy would be trouble! Thanks tiny ad!
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!