6 kyu

Product Partitions I

101 of 122raulbc777

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:

  1. each product will be expressed in a list of its factors in incresing order from left to right

  2. 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!!

Fundamentals
Algorithms
Mathematics

Stats:

CreatedOct 6, 2015
PublishedOct 6, 2015
Warriors Trained879
Total Skips54
Total Code Submissions1579
Total Times Completed122
Python Completions101
JavaScript Completions27
Ruby Completions6
Total Stars19
% of votes with a positive feedback rating79% of 42
Total "Very Satisfied" Votes30
Total "Somewhat Satisfied" Votes6
Total "Not Satisfied" Votes6
Total Rank Assessments6
Average Assessed Rank
6 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • raulbc777 Avatar
  • KenKamau Avatar
  • bidouille Avatar
  • user9644768 Avatar
Ad