Jump to content

Permutator Help

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1
Victor

Victor

    Programmer

  • Members
  • PipPipPipPip
  • 116 posts
Came across this class for permutating a set of values. When executed, it dumps the permutations to System.out. My question: is there a way to get each permuted value as a string or int instead/as well?

Much appreciated

Perm.java

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
I haven't looked at the linked code, but putting the data into an array should work.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
Victor

Victor

    Programmer

  • Members
  • PipPipPipPip
  • 116 posts
Could you take a look at it? I'm not sure how exactly to go about it

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Having just looked at the code, are you aware of how many permutations of the string "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" there are? While you could (in theory) produce all the permutations, to store them in memory will cause a memory overflow on any computer in existence.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
Victor

Victor

    Programmer

  • Members
  • PipPipPipPip
  • 116 posts
This is just the code I based mine off of. The string I'm using is much shorter

#6
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Just realize that, given a string of length n, the memory required to store it will be approximately n*(n!) bytes, more if using unicode strings.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog