Group Abstract Group Abstract

Message Boards Message Boards

0
|
38 Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:

How to count lists with identical elements in different orders as one class?

Posted 1 day ago
set = Tuples[{DD, Dd, Dd, dd}, 2]
    Counts[set, {{DD, Dd}, {Dd, DD}}]

We treat two lists like {DD, Dd} and {Dd, DD} as the same category or identical, since they contain the same elements in different orders.

Under this rule, they count as 2.

Following the same rule, how can we make {DD, Dd} in a set count as 4? The counting rule for other lists remains consistent.

POSTED BY: Bill Blair
2 Replies
Posted 1 day ago

Thank you, that's exactly the result I wanted to achieve.

POSTED BY: Bill Blair
Posted 1 day ago

I'm not quite sure what you mean, but you might want to compare the functionality of Counts with the functionality of GroupBy. For example:

GroupBy[set, Sort, Length]
(* <|{DD, DD} -> 1, {Dd, DD} -> 4, {dd, DD} -> 2, {Dd, Dd} -> 4, {dd, Dd} -> 4, {dd, dd} -> 1|> *)

Maybe you can do something with that.

POSTED BY: Eric Rimbey
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard