Comment detail

自然数の分割 (Nested Flatten)

This comment is reply for 4572 matyr: (自然数の分割). Go to thread root.

fiber を使って書き換えてみる。
1
2
3
4
5
6
(|n, m|{ c: callee; m--;
  return fiber{
    if(m < 1) yield [n];
    else (n + 1).times{|x| c(x, m){ yield [n - x] ~ it; } }
  }
})(5, 3).join("\n").p;

Index

Feed

Other

Link

Pathtraq

loading...