#TI-BASIC, (削除) 106 (削除ここまで) 94 bytes
Prompt N,B
"∟B(1+remainder(n,dim(∟B→u
{1
For(I,1,N
Disp Ans
augment({0},Ans)+augment(Ans,{0
seq(Ans(X) and 2-Ans(X)+u(n-(Ans(X)<2)+dim(∟B)),X,1,dim(Ans
End
This program uses a special property of the equation variable u: when u is called with an argument, the variable n is set to one greater than that argument. For list indexing to work properly, n must be its default value of 0, and nMin should be its default 1, so either clear your calculator's RAM or set those values manually before running this.
Test case:
N=?7
B=?{0,1,0
{1}
{1 1}
{1 0 1}
{1 1 1 1}
{1 1 0 0 1}
{1 1 1 0 1 1}
{1 0 0 1 1 1 1}
Done
lirtosiast
- 21.6k
- 5
- 53
- 127