Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As I understand it, you are effectively asking for ways of partitioning the interval [100,199] into 10 parts, i.e. you want to find numbers x[0], ..., x[10] such that:</p> <pre><code>x[0] = 100 &lt; x[1] &lt; x[2] &lt; ... &lt; x[9] &lt; x[10] = 199 </code></pre> <p>Define a recursive function <code>partition(intervalSize, pieces)</code> which counts the number of ways to partition a given interval. You are after <code>partition(100, 10)</code>.</p> <p>The following Java code counts the partitions (sorry, don't know PHP that well):</p> <pre><code>public class Partitions { static long[][] partitions = new long[100][10]; private static long partition(int intervalSize, int pieces) { if (partitions[intervalSize-1][pieces-1] != 0) { return partitions[intervalSize-1][pieces-1]; } long partition = 0L; if (pieces == 1) { partition = 1L; } else { for (int i = 1; i &lt;= intervalSize - 1; i++) { partition += partition(intervalSize - i, pieces - 1); } } partitions[intervalSize-1][pieces-1] = partition; return partition; } public static void main(String[] args) { System.out.println(partition(100, 10)); } } </code></pre> <p>The following Java code prints out the actual partitions. Because the number of partitions is so high for (100,10), I'm illustrating the answer for (5,3):</p> <pre><code>public class Partitions2 { private static void showPartitions(int sizeSet, int numPartitions) { showPartitions("", 0, sizeSet, numPartitions); } private static void showPartitions(String prefix, int start, int finish, int numLeft) { if (numLeft == 0 &amp;&amp; start == finish) { System.out.println(prefix); } else { prefix += "|"; for (int i = start + 1; i &lt;= finish; i++) { prefix += i + ","; showPartitions(prefix, i, finish, numLeft - 1); } } } public static void main(String[] args) { showPartitions(5, 3); } } </code></pre> <p>The output is:</p> <pre> |1,|2,|3,4,5, |1,|2,3,|4,5, |1,|2,3,4,|5, |1,2,|3,|4,5, |1,2,|3,4,|5, |1,2,3,|4,|5, </pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload