Product Partitions I
Description:
Given a natural number n, we want to know in how many ways we may express these numbers as product of other numbers.
For example the number
18 = 2 x 9 = 3 x 6 = 2 x 3 x 3 # (we do not consider the product 18 x 1), (3 ways)
See this example a bit more complicated,
60 = 2 x 30 = 3 x 20 = 4 x 15 = 5 x 12 = 6 x 10 = 2 x 2 x 15 = 2 x 3 x 10 = 2 x 5 x 6 = 3 x 4 x 5 = 2 x 2 x 3 x 5 (10 ways)
We need the function prod_int_part()
, that receives a number n, and ouputs the amount of total different products with all the products of max length sorted in this way:
each product will be expressed in a list of its factors in incresing order from left to right
if there is more than one list-product, these lists should be ordered by the value of the first term, if two lists have the same term equal thay should be ordered by the value of the second term.
Let's see some cases:
prod_int_part(18) == [3, [2, 3, 3]]
prod_int_part(60) == [10, [2, 2, 3, 5]
If we have only one list-product with the maximum length, there is no use to have it with two nested braces, so the result will be like this case:
prod_int_part(54) == [6, [2, 3, 3, 3]]
Now, let's see examples when n
cannot be partitioned:
prod_int_part(37) == [0, []]
prod_int_part(61) == [0, []]
Enjoy it!!
Similar Kata:
Stats:
Created | Oct 6, 2015 |
Published | Oct 6, 2015 |
Warriors Trained | 879 |
Total Skips | 54 |
Total Code Submissions | 1579 |
Total Times Completed | 122 |
Python Completions | 101 |
JavaScript Completions | 27 |
Ruby Completions | 6 |
Total Stars | 19 |
% of votes with a positive feedback rating | 79% of 42 |
Total "Very Satisfied" Votes | 30 |
Total "Somewhat Satisfied" Votes | 6 |
Total "Not Satisfied" Votes | 6 |
Total Rank Assessments | 6 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 4 kyu |
Lowest Assessed Rank | 7 kyu |