<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>obelisk2</author_name>
  <author_url>https://blog.hatena.ne.jp/obelisk2/</author_url>
  <blog_title>Camera Obscura</blog_title>
  <blog_url>https://obelisk.hatenablog.com/</blog_url>
  <categories>
    <anon>Ruby</anon>
  </categories>
  <description>def divide(x, n) result = [] return [] if n.zero? return [[0] * n] if x.zero? return [[x]] if n == 1 0.upto(x) do |i| result += divide(x - i, n - 1).map {|a| a + [i]} end result end p divide(5, 3) 結果。5 を 3つに分割している。 [[5, 0, 0], [4, 1, 0], [3, 2, 0], [2, 3, 0], [1, 4, 0], [0, 5, 0], [4, 0, 1], [3, 1, …</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fobelisk.hatenablog.com%2Fentry%2F2018%2F10%2F09%2F162738&quot; title=&quot;自然数を n 個に分割する &amp;amp; 重複組み合わせ（Ruby） - Camera Obscura&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2018-10-09 16:27:38</published>
  <title>自然数を n 個に分割する &amp; 重複組み合わせ（Ruby）</title>
  <type>rich</type>
  <url>https://obelisk.hatenablog.com/entry/2018/10/09/162738</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
