hmm.. i'm trying to think of an algorithm that takes a list of elements and returns a list with every way to take the elements of that list and split it up into smaller lists, so that every element is in exactly one of the smaller lists

i can't even think of a way to phrase it, let alone program it

Β· Β· Web Β· 4 Β· 0 Β· 2

like if i put in [1, 2, 3] i want to get out

[[1, 2, 3]],
[[1, 2], [3]],
[[1, 3], [2]],
[[2, 3], [1]],
[[1], [2], [3]]

every way to split up the input list into smaller lists

@monorail i think there is something you could probably do starting from calculating the power set though?

@monorail btw what about [[2, 1], [3]] and [[3], [1, 2]] and whatnot?

@monorail itertools has powerset which is almost what you want I think

@monorail so you're looking for the set of all partitions of a set

i don't have anything off the top of my head but hopefully the name helps

@monorail I'm bad at set theory so there's a high chance I'm misunderstanding or wrong but would this be like, different decompositions of the set

@Dee oh shit i think this is exactly what i want, thank you!

Sign in to participate in the conversation

A general fediverse instance for people who generally like pokemon at least a little bit. Newly registered users must be manually approved due to an increasing number of spam bots; if you look like a person, your account will be approved as soon as possible.