Cody

# Problem 2595. Polite numbers. Politeness.

Solution 1936569

Submitted on 15 Sep 2019 by Augusto Mazzei
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
x = 1; y_correct = 0; assert(isequal(politeness(x),y_correct))

f = 1 ff = 1 cnt = 1 ans = [] P = 0

2   Pass
x = 2; y_correct = 0; assert(isequal(politeness(x),y_correct))

f = 2 ff = 2 cnt = 1 ans = [] P = 0

3   Pass
x = 3; y_correct = 1; assert(isequal(politeness(x),y_correct))

f = 3 ff = 3 cnt = 1 ans = 1 P = 1

4   Pass
x = 7; y_correct = 1; assert(isequal(politeness(x),y_correct))

f = 7 ff = 7 cnt = 1 ans = 1 P = 1

5   Pass
x = 9; y_correct = 2; assert(isequal(politeness(x),y_correct))

f = 3 3 ff = 3 cnt = 2 ans = 2 P = 2

6   Pass
x = 15; y_correct = 3; assert(isequal(politeness(x),y_correct))

f = 3 5 ff = 3 5 cnt = 1 1 ans = 1 1 P = 3

7   Pass
x = 18; y_correct = 2; assert(isequal(politeness(x),y_correct))

f = 2 3 3 ff = 2 3 cnt = 1 2 ans = 2 P = 2

8   Pass
x = 21; y_correct = 3; assert(isequal(politeness(x),y_correct))

f = 3 7 ff = 3 7 cnt = 1 1 ans = 1 1 P = 3

9   Pass
x = 1024; y_correct = 0; assert(isequal(politeness(x),y_correct))

f = 2 2 2 2 2 2 2 2 2 2 ff = 2 cnt = 10 ans = [] P = 0

10   Pass
x = 1025; y_correct = 5; assert(isequal(politeness(x),y_correct))

f = 5 5 41 ff = 5 41 cnt = 2 1 ans = 2 1 P = 5

11   Pass
x = 25215; y_correct = 11; assert(isequal(politeness(x),y_correct))

f = 3 5 41 41 ff = 3 5 41 cnt = 1 1 2 ans = 1 1 2 P = 11

12   Pass
x = 62; y_correct = 1; assert(isequal(politeness(x),y_correct))

f = 2 31 ff = 2 31 cnt = 1 1 ans = 1 P = 1

13   Pass
x = 63; y_correct = 5; assert(isequal(politeness(x),y_correct))

f = 3 3 7 ff = 3 7 cnt = 2 1 ans = 2 1 P = 5

14   Pass
x = 65; y_correct = 3; assert(isequal(politeness(x),y_correct))

f = 5 13 ff = 5 13 cnt = 1 1 ans = 1 1 P = 3

15   Pass
% anti-lookup & clue nums=primes(200); pattern=[1 nums([false ~randi([0 25],1,45)])]; x=prod(pattern)*2^randi([0 5]); y_correct=2^numel(pattern)/2-1; assert(isequal(politeness(x),y_correct))

f = 2 2 2 59 197 ff = 2 59 197 cnt = 3 1 1 ans = 1 1 P = 3

16   Pass
for k=randi(2e4,1,20) assert(isequal(politeness(k*(k-1))+1,(politeness(k)+1)*(politeness(k-1)+1))) end

f = 2 2 3 5 7 19 173 239 ff = 2 3 5 7 19 173 239 cnt = 2 1 1 1 1 1 1 ans = 1 1 1 1 1 1 P = 63 f = 3 5 7 173 ff = 3 5 7 173 cnt = 1 1 1 1 ans = 1 1 1 1 P = 15 f = 2 2 19 239 ff = 2 19 239 cnt = 2 1 1 ans = 1 1 P = 3 f = 2 2 3 5 7 7 79 1613 ff = 2 3 5 7 79 1613 cnt = 2 1 1 2 1 1 ans = 1 1 2 1 1 P = 47 f = 2 2 3 1613 ff = 2 3 1613 cnt = 2 1 1 ans = 1 1 P = 3 f = 5 7 7 79 ff = 5 7 79 cnt = 1 2 1 ans = 1 2 1 P = 11 f = 2 2 2 2 7 41 4591 ff = 2 7 41 4591 cnt = 4 1 1 1 ans = 1 1 1 P = 7 f = 2 2 2 2 7 41 ff = 2 7 41 cnt = 4 1 1 ans = 1 1 P = 3 f = 4591 ff = 4591 cnt = 1 ans = 1 P = 1 f = 2 3 3 5 11 13 19 1447 ff = 2 3 5 11 13 19 1447 cnt = 1 2 1 1 1 1 1 ans = 2 1 1 1 1 1 P = 95 f = 13 1447 ff = 13 1447 cnt = 1 1 ans = 1 1 P = 3 f = 2 3 3 5 11 19 ff = 2 3 5 11 19 cnt = 1 2 1 1 1 ans = 2 1 1 1 P = 23 f = 2 7 31 139 1231 ff = 2 7 31 139 1231 cnt = 1 1 1 1 1 ans = 1 1 1 1 P = 15 f = 2 31 139 ff = 2 31 139 cnt = 1 1 1 ans = 1 1 P = 3 f = 7 1231 ff = 7 1231 cnt = 1 1 ans = 1 1 P = 3 f = 2 3 6091 9137 ff = 2 3 6091 9137 cnt = 1 1 1 1 ans = 1 1 1 P = 7 f = 2 9137 ff = 2 9137 cnt = 1 1 ans = 1 P = 1 f = 3 6091 ff = 3 6091 cnt = 1 1 ans = 1 1 P = 3 f = 2 2 3 883 10597 ff = 2 3 883 10597 cnt = 2 1 1 1 ans = 1 1 1 P = 7 f = 10597 ff = 10597 cnt = 1 ans = 1 P = 1 f = 2 2 3 883 ff = 2 3 883 cnt = 2 1 1 ans = 1 1 P = 3 f = 2 2 3 43 101 3257 ff = 2 3 43 101 3257 cnt = 2 1 1 1 1 ans = 1 1 1 1 P = 15 f = 3 43 101 ff = 3 43 101 cnt = 1 1 1 ans = 1 1 1 P = 7 f = 2 2 3257 ff = 2 3257 cnt = 2 1 ans = 1 P = 1 f = 2 3 3 3 5 67 18089 ff = 2 3 5 67 18089 cnt = 1 3 1 1 1 ans = 3 1 1 1 P = 31 f = 2 3 3 3 5 67 ff = 2 3 5 67 cnt = 1 3 1 1 ans = 3 1 1 P = 15 f = 18089 ff = 18089 cnt = 1 ans = 1 P = 1 f = 2 2 3 3 5 19 97 919 ff = 2 3 5 19 97 919 cnt = 2 2 1 1 1 1 ans = 2 1 1 1 1 P = 47 f = 19 919 ff = 19 919 cnt = 1 1 ans = 1 1 P = 3 f = 2 2 3 3 5 97 ff = 2 3 5 97 cnt = 2 2 1 1 ans = 2 1 1 P = 11 f = 2 5 7 7 17 8329 ff = 2 5 7 17 8329 cnt = 1 1 2 1 1 ans = 1 2 1 1 P = 23 f = 2 5 7 7 17 ff = 2 5 7 17 cnt = 1 1 2 1 ans = 1 2 1 P = 11 f = 8329 ff = 8329 cnt = 1 ans = 1 P = 1 f = 2 2 3 17 29 61 97 ff = 2 3 17 29 61 97 cnt = 2 1 1 1 1 1 ans = 1 1 1 1 1 P = 31 f = 61 97 ff = 61 97 cnt = 1 1 ans = 1 1 P = 3 f = 2 2 3 17 29 ff = 2 3 17 29 cnt = 2 1 1 1 ans = 1 1 1 P = 7 f = 2 3 3 43 43 53 157 ff = 2 3 43 53 157 cnt = 1 2 2 1 1 ans = 2 2 1 1 P = 35 f = 2 53 157 ff = 2 53 157 cnt = 1 1 1 ans = 1 1 P = 3 f = 3 3 43 43 ff = 3 43 cnt = 2 2 ans = 2 2 P = 8 f = 2 7 13 19 41 839 ff = 2 7 13 19 41 839 cnt = 1 1 1 1 1 1 ans = 1 1 1 1 1 P = 31 f = 13 839 ff = 13 839 cnt = 1 1 ans = 1 1 P = 3 f = 2 7 19 41 ff = 2 7 19 41 cnt = 1 1 1 1 ans = 1 1 1 P = 7 f = 2 2 7 109 191 ff = 2 7 109 191 cnt = 2 1 1 1 ans = 1 1 1 P = 7 f = 2 2 191 ff = 2 191 cnt = 2 1 ans = 1 P = 1 f = 7 109 ff = 7 109 cnt = 1 1 ans = 1 1 P = 3 f = 2 2 2 2 3 3 19 83 887 ff = 2 3 19 83 887 cnt = 4 2 1 1 1 ans = 2 1 1 1 P = 23 f = 3 3 19 83 ff = 3 19 83 cnt = 2 1 1 ans = 2 1 1 P = 11 f = 2 2 2 2 887 ff = 2 887 cnt = 4 1 ans = 1 P = 1 f = 2 2 2 7 7 7 13 211 ff = 2 7 13 211 cnt = 3 3 1 1 ans = 3 1 1 P = 15 f = 2 2 2 7 7 7 ff = 2 7 cnt = 3 3 ans = 3 P = 3 f = 13 211 ff = 13 211 cnt = 1 1 ans = 1 1 P = 3 f = 2 137 139 9521 ff = 2 137 139 9521 cnt = 1 1 1 1 ans = 1 1 1 P = 7 f = 137 139 ff = 137 139 cnt = 1 1 ans = 1 1 P = 3 f = 2 9521 ff = 2 9521 cnt = 1 1 ans = 1 P = 1 f = 2 2 7 509 14251 ff = 2 7 509 14251 cnt = 2 1 1 1 ans = 1 1 1 P = 7 f = 2 2 7 509 ff = 2 7 509 cnt = 2 1 1 ans = 1 1 P = 3 f = 14251 ff = 14251 cnt = 1 ans = 1 P = 1 f = 2 3 5 7 7 19 41 53 ff = 2 3 5 7 19 41 53 cnt = 1 1 1 2 1 1 1 ans = 1 1 2 1 1 1 P = 95 f = 3 7 7 53 ff = 3 7 53 cnt = 1 2 1 ans = 1 2 1 P = 11 f = 2 5 19 41 ff = 2 5 19 41 cnt = 1 1 1 1 ans = 1 1 1 P = 7