• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

filling arrays with numbers in the most possible ways

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, I am struggling with filling int arrays in the most possible ways.

Lets say I am creating int arrays length of 5 and I pick numbers to it between 1 to 70. In one array there is never same number twice and
the next created array will not have exactly the same numbers sequence that the previous ones had.
Creation of arrays stops only when all possible number sequences are created.

And yes this is for Keno numbers, stupid hobby of mine but it spends time





In this method numbers are processed as follows...

{1, 2, 3, 4, 5}
{1, 2, 3, 4, 6}
.
{1, 2, 3, 4, 70}

{1, 2, 3, 5, 6}
{1, 2, 3, 5, 7}
.
{1, 2, 3, 5, 70}

{1, 2, 3, 6, 7}
{1, 2, 3, 6, 8}
.
{1, 2, 3, 6, 70}

and so on...................

In the end, sum of number sequences for level 5 is 8645 and thats not enough.

If you feel that you could have strength to process this, thanks in advance
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, lets start with:

"How many sequences are you expecting?"...
 
Mikko Kohtamäki
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Martijn Verburg wrote:OK, lets start with:

"How many sequences are you expecting?"...



If level is 5 then would it be 70 raised to the 5th power minus 70 times 5.
= 1680700000 - 350 = 1680699650

woo, i'm not so good in math as i should be
 
Bartender
Posts: 612
7
Mac OS X Python
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I get 12,103,014

which is 70! / 5! 65!
 
Martijn Verburg
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And is 1,2,3,4,5 different to say 5,4,3,2,1?
 
Steve Fahlbusch
Bartender
Posts: 612
7
Mac OS X Python
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Martin i would say not.

Keno - as far as i am know does not care when you pick say 1, just that 1 was picked.

so

1,2,3,4,5 == 2,1,3,4,5 == 5,4,3,2,1
 
Martijn Verburg
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In that case then yes a factorial based formula will be 'better' than a power of formula. So, now that we have a formula, can you see a way of coding that? *Hint* There are plenty of sample code algorithms out there...
 
Mikko Kohtamäki
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, i have tried many permutation algorithms and modified them eg........ But then i found the one that does the job from http://mindprod.com/jgloss/permutation.html

With help of VariatorWithRepetition class.



It needs some modifying, but i'm relieved

Thanks for your help.
 
Martijn Verburg
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome and well done on finding a solution!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic