Ask Your Question
0

Seeking an efficient filter for partitions.

asked 2015-07-13 11:38:26 +0100

Peter Luschny gravatar image

updated 2015-07-13 19:46:53 +0100

From the docs:

sage: Partitions(4, max_part=2).list()
[[2, 2], [2, 1, 1], [1, 1, 1, 1]]

I find this parlance confusing. Obviously the partition [1, 1, 1, 1] has no max part = 2. Be that as it may, I do want to filter those partitions which greatest part is 2, so in the example would return

[[2, 2], [2, 1, 1]].

What is the most efficient way to implement

P(n,k) = Partitions(n, MAX_PART=k)

where MAX_PART is defined in my sense?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2015-07-13 13:14:52 +0100

Nathann gravatar image

Would this work?

sage: Partitions(4, max_part=2,inner=[2]).list()
[[2, 2], [2, 1, 1]]
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-07-13 11:38:26 +0100

Seen: 514 times

Last updated: Jul 13 '15