help-octave
[Top][All Lists]
Advanced

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

Re: longuest interleaved sequences


From: Judd Storrs
Subject: Re: longuest interleaved sequences
Date: Thu, 20 May 2010 16:19:35 -0400

On Thu, May 20, 2010 at 3:39 PM, Jaroslav Hajek <address@hidden> wrote:
> what about
>
>  x = sort(rand(50,1)) ;
>  y = sort(rand(54,1)) ;
>
> [~, ix] = unique (lookup (y, x));
> x = x(ix);
> [~, iy] = unique (lookup (x, y));
> y = y(iy);
>
> and remove one element from the longer sequence if needed.

I think this generates an interleaved subset of x and y that is
longest. It tosses values out, though. I was trying to find the
longest continuous subsequence. Your code finds the longest (possibly
non-continuous) subsequence which may be what Pascal was wanting. I
always forget about lookup() ;)


--judd



reply via email to

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