整数分割1

整数分割の方法のアルゴリズム、

  1. The first integer partition of n is [n](最初のパーティションは [n]
  2. B consists only 1’s, then done(パーティションが1のみで構成されたなら終了)
  3. there is a smallest non-1 part m(リストのうち1以外の最小数を m と置く)
  4. subtract 1 from mmから1を引く)
  5. collect all the units so as to much the new smallest part m -1(残りの要素すべてを最大でm-1となるようすべて集める)

最後がかなり怪しい訳になった。このアルゴリズの例が、

The partition after [1, 1, 3, 3] is [1, 2, 2, 3], for after subtracting 1 from 3, we should pack the three units that result in parcels of size 2. The partition after [1, 1, 1, 1, 1, 1, 5] is [3, 4, 4], for after subtracting 1 from 5, we should pack the seven units that result in parcels with maximum size 4, which gives three units and one parcel of size 4, which in turn gives one parcel of size 3 and one of size 4. The partition after [3, 3, 5] is [1, 2, 3, 5]. The partition after [1, 3, 3, 4] is [2, 2, 3, 4].

これ。理解できてないのでコードが書けん。