Ask Your Question
0

Seeking an efficient filter for partitions.

asked 2015-07-13 04:38:26 -0500

Peter Luschny gravatar image

updated 2015-07-13 12:46:53 -0500

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
1

answered 2015-07-13 06:14:52 -0500

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 04:38:26 -0500

Seen: 230 times

Last updated: Jul 13 '15