help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Too many permutations computed


From: uzibalqa
Subject: Re: Too many permutations computed
Date: Thu, 03 Aug 2023 16:49:04 +0000





Sent with Proton Mail secure email.

------- Original Message -------
On Friday, August 4th, 2023 at 3:42 AM, uzibalqa <uzibalqa@proton.me> wrote:


> ------- Original Message -------
> On Wednesday, August 2nd, 2023 at 10:13 PM, Emanuel Berg incal@dataswamp.org 
> wrote:
> 
> > uzibalqa wrote:
> > 
> > > (while (< j h) [...]
> > > (setq j (1+ j)))
> > > [...]
> > > for i := 0; i < k-1; i += 1 do [...]
> > 
> > You can replace that `while' with a for loop using` cl-loop'
> > and for, to make it a closer match to the pseudo-code.
> > 
> > This: (setq j (1+ j)) can be replaced by `cl-incf' as in
> > (cl-incf j) - but better yet is to get away with that and use
> > a for loop to iterate instead.

After doing 

     (cl-loop for j from 0 below (- h 1) do

I get the correct results.
 
> > Again you can check out these two
> > 
> > https://dataswamp.org/~incal/emacs-init/perm.el
> > https://www.emacswiki.org/emacs/StringPermutations
> > 
> > but after spending so much time on your own solution I get it
> > you want to complete it ...

There are many algorithms out there.  You should mention the kind
of algorithm you are implementing.  

I am using the original algorithm bf Robert Heap (1964).  It is not  
the common implementation you see because what I have seen is the
implementation of a simpler algorithm (programatically), but which
is not optimal in the way Robert constructed it.  
 
> Obviously, my implementation is not computing things as expected.
> My current focus is to get it to work by being as close as possible
> to the algorithm so I can get it working as it should.
> 
> > --
> > underground experts united
> > https://dataswamp.org/~incal



reply via email to

[Prev in Thread] Current Thread [Next in Thread]