16
1
The Steenrod algebra is an important algebra that comes up in algebraic topology. The Steenrod algebra is generated by operators called "Steenrod squares," one exists for each positive integer i. There is a basis for the Steenrod algebra consisting of "admissible monomials" in the squaring operations. It is our goal to generate this basis.
A sequence of positive integers is called admissible if each integer is at least twice the next one. So for instance [7,2,1]
is admissible because \$7 \geq 2*2\$ and \$2 \geq 2*1\$. On the other hand, [3,2]
is not admissible because \$3 < 2*2\$. (In topology we would write \$\mathrm{Sq}^7 \mathrm{Sq}^2\mathrm{Sq}^1\$ for the sequence [7,2,1]
).
The degree of a sequence is the total of it's entries. So for instance, the degree of [7,2,1]
is \$7 + 2 + 1 = 10\$. The excess of an admissible sequence is the first element minus the total of the remaining elements, so [7,2,1]
has excess \$7 - 2 - 1 = 4\$.
Task
Write a program that takes a pair of positive integers (d,e)
and outputs the set of all admissible sequences of degree d
and excess less than or equal to e
. The output is a set so the order of the admissible sequences doesn't matter.
Examples:
Input: 3,1
Output: [[2,1]]
Here we are looking for admissible sequences with total 3. There are two options, [3]
and [2,1]
. ([1,1,1]
and [1,2]
have sum 3 but are not admissible). The excess of [3]
is 3 and the excess of [2,1]
is \$2-1 = 1\$. Thus, the only sequence with excess \$\leq1\$ is [2,1]
.
Input: 6, 6
Output: [[6], [5, 1], [4, 2]] (or any reordering, e.g., [[5,1],[4,2],[6]])
Since excess is always less than or equal to degree, we have no excess condition. Thus, we're just trying to find all admissible sequences of degree 6. The options are [6]
, [5, 1]
, and [4, 2]
. (These have excess \$6\$, \$5-1 = 4\$, and \$4-2=2\$.)
Input: 10, 5
Output: [[7,3], [7,2,1], [6,3,1]]
The admissible sequences of degree 10 are:
[[10], [9,1], [8,2], [7,3], [7,2,1], [6,3,1]]
These have excess \$10\$, \$9-1 = 8\$, \$8-2 = 6\$, \$7-3 = 4\$, \$7-2-1 = 4\$, and \$6-3-1=2\$ respectively, so the last three all work.
Scoring
This is code golf: Shortest solution in bytes wins.
Test cases:
Any reordering of the output is equally good, so for input (3, 3)
, outputs [[3],[2,1]]
or [[2,1],[3]]
are equally acceptable (however [[1,2],[3]]
isn't).
Input: 1, 1
Output: [[1]]
Input: 3, 3
Output: [[2,1], [3]]
Input: 3, 1
Output: [[2,1]]
Input: 6, 6
Output: [[6], [5, 1], [4, 2]]
Input: 6, 4
Output: [[5,1], [4,2]]
Input: 6, 1
Output: []
Input: 7, 7
Output: [[7], [6,1], [4,2,1], [5,2]]
Input: 7,1
Output: [[4,2,1]]
Input: 10, 10
Output: [[10], [9,1], [7,2,1], [6,3,1], [8,2], [7,3]]
Input: 10, 5
Output: [[7,3], [7,2,1], [6,3,1]]
Input: 26, 4
Output: [15, 7, 3, 1]
Input: 26, 6
Output: [[16, 7, 2, 1], [16, 6, 3, 1], [15, 7, 3, 1], [16, 8, 2], [16, 7, 3]]
1Okay, I will provide a brief explanation. – Hood – 2019-06-05T15:51:15.417