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

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

Re: Finding repetitions of 8-tuples


From: Yuri Khan
Subject: Re: Finding repetitions of 8-tuples
Date: Sun, 1 Jan 2023 23:39:36 +0700

On Sun, 1 Jan 2023 at 22:19, Arthur Miller <arthur.miller@live.com> wrote:

> > I have 16 collections of 8 numbers
> >
> > (11 12 11 44 11 12 11 23)
> > (12 21 11 44 11 12 11 23)
> > and so on
> >
> > I want to find whether there are repetitions of each 8-tuple.
> > The order in which the numbers occur is not important.
>
> Have you looked at "lists as sets" chapter in the manual?

This line of thought leads nowhere because treating a list as a set
ignores its duplicate counts. I take it that in the OP’s problem
statement (1 1 1 1 1 2 2 2) is to be considered distinct from (1 1 1 1
2 2 2 2), but, treated as sets, they are both equivalent to (1 2). The
original problem calls for multisets — containers where the order is
not significant but the counts of duplicates are.

Sorting each list and comparing the result of sorting, as suggested in
another reply, is going to be a better approach.

Alternatively, one might hash each element and xor the hashes
together. However, this carries collision risk inherent in hash-based
solutions — if hashes are different, the multisets are different, but
if the hashes are equal, this does not guarantee the equality of
multisets.



reply via email to

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