Re: permutation algorithm

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



JRS: In article <Oo4mQHdnFHA.3316@xxxxxxxxxxxxxxxxxxxx>, dated Wed, 10
Aug 2005 12:34:50, seen in news:microsoft.public.scripting.vbscript,
Roland Hall <nobody@nowhere.?> posted :
>"Dr John Stockton" wrote in message
>news:YMD6vyARkl9CFwJ9@xxxxxxxxxxxxxxxxxxxxx
>: JRS: In article <#NxvSqlmFHA.2904@xxxxxxxxxxxxxxxxxxxx>, dated Sat, 6
>: Aug 2005 02:43:41, seen in news:microsoft.public.scripting.vbscript,
>: Roland Hall <nobody@nowhere.?> posted :
>:
>: >I'm not sure what type of permutation should would be but I'm trying to
>get
>: >all possible combinations of a string.
>:
>: Combinations are not permutations (in my English).
>
>Sorry to hear that.

You'll see the appropriate usage on the cited page. In a combination,
order does not matter; in a permutation, it does.

>: You can, no doubt, translate the code visible and demonstrated in
>: <URL:http://www.merlyn.demon.co.uk/js-tests.htm#CP>; it could do with
>: independent verification. You'll want to use .split() on your string as
>: a start.
>
>That doesn't work in vbscript.

Use .split() *before* translating to VBScript, so that in the
translation it too is translated <G>.

>: The general approach is to write a function that selects whatever is
>: possible as the first character then calls itself to deal with what is
>: left.
>
>I'm actually looking for the word declining combinations, instead of just
>characters, which y sakuda was so helpful in providing. However, I'm always
>willing to see other possibilities.

The code works on the elements of an array S, which can be whatever
Objects one chooses; characters have an obvious advantage for
convenience of collection and brevity of display. For non-characters,
the expression z+a[j] should be changed to build the result into an
array rather than a string. In the paragraph you quoted, I should have
used 'entity' or 'object' rather than 'character'.

>The j(ava)script routine on your site puts a single comma in the beginning
>and also ends with one. Shouldn't they only be found within the result?

If you mean that after the comma-separated list of items there was
another comma, that's merely an artefact of the previous crude provision
for display.

Change D = "" to D = [] & D += z + "," to D[D.length] = z .

Thanks for causing the thought. D has also been made non-global.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
.



Relevant Pages

  • Re: Perl Regex Question: how to translate only the leading lettersofaline
    ... clearly will translate all occurrances of "3" to "C", ... regardless of where the characters appear in the string. ... regardless of where they characters appear in the string. ...
    (comp.lang.perl.misc)
  • Re: Convert HTML to String
    ... not be used in this context, you used "const char *" when you meant LPCTSTR, you are ... with what might happen if a was found inside a quoted string for an HTML parameter ... Here's an example string I'd like to translate: ... // Get the next two characters ...
    (microsoft.public.vc.mfc)
  • Re: Convert HTML to String
    ... Here's an example string I'd like to translate: ... // Remove the characters translated ... strBody.Delete(startPos, 3); ...
    (microsoft.public.vc.mfc)
  • Re: Shorten Code for repeated function use
    ... PL/I and REXX it is Translate, ... the "to" string in REXX and the "from" string is the characters ... ASCII except that characters are not actually two way reversible). ... >> a way to set up an array and get the function to work ...
    (microsoft.public.excel.programming)
  • One-way function that maps hexadecimal string onto alphanumeric string
    ... Find a function F that transforms a string H into a string A, ... If the characters H_i occur with a probability 1/16, ... This function G performs a substitution followed by a permutation. ...
    (sci.crypt)