Cody

# Problem 2595. Polite numbers. Politeness.

Solution 913749

Submitted on 22 Jun 2016 by hubert andre
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 c = [] y = 0

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

f = 2 c = [] y = 0

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

f = 3 c = 1 y = 1

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

f = 7 c = 1 y = 1

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

f = 3 3 c = 2 y = 2

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

f = 3 5 c = 1 1 y = 3

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

f = 2 3 3 c = 2 y = 2

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

f = 3 7 c = 1 1 y = 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 c = Empty matrix: 1-by-0 y = 0

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

f = 5 5 41 c = 2 1 y = 5

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

f = 3 5 41 41 c = 1 1 2 y = 11

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

f = 2 31 c = 1 y = 1

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

f = 3 3 7 c = 2 1 y = 5

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

f = 5 13 c = 1 1 y = 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 3 c = 1 y = 1

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 2 2 3 3 137 19727 c = 2 1 1 y = 11 f = 2 2 2 2 3 3 137 c = 2 1 y = 5 f = 19727 c = 1 y = 1 f = 2 3 5 31 167 1553 c = 1 1 1 1 1 y = 31 f = 3 31 167 c = 1 1 1 y = 7 f = 2 5 1553 c = 1 1 y = 3 f = 2 5 1697 4243 c = 1 1 1 y = 7 f = 2 4243 c = 1 y = 1 f = 5 1697 c = 1 1 y = 3 f = 2 2 3 5 421 1579 c = 1 1 1 1 y = 15 f = 2 2 1579 c = 1 y = 1 f = 3 5 421 c = 1 1 1 y = 7 f = 2 29 53 127 139 c = 1 1 1 1 y = 15 f = 53 139 c = 1 1 y = 3 f = 2 29 127 c = 1 1 y = 3 f = 2 2 3 3 541 19477 c = 2 1 1 y = 11 f = 19477 c = 1 y = 1 f = 2 2 3 3 541 c = 2 1 y = 5 f = 2 3 3 5 19 239 283 c = 2 1 1 1 1 y = 47 f = 3 3 5 239 c = 2 1 1 y = 11 f = 2 19 283 c = 1 1 y = 3 f = 2 13 71 79 863 c = 1 1 1 1 y = 15 f = 13 863 c = 1 1 y = 3 f = 2 71 79 c = 1 1 y = 3 f = 2 5 3019 7547 c = 1 1 1 y = 7 f = 5 3019 c = 1 1 y = 3 f = 2 7547 c = 1 y = 1 f = 2 3 13 29 109 1459 c = 1 1 1 1 1 y = 31 f = 13 1459 c = 1 1 y = 3 f = 2 3 29 109 c = 1 1 1 y = 7 f = 2 2 3 3 43 109 2083 c = 2 1 1 1 y = 23 f = 2 2 43 109 c = 1 1 y = 3 f = 3 3 2083 c = 2 1 y = 5 f = 2 3 3 17 59 4513 c = 2 1 1 1 y = 23 f = 3 3 17 59 c = 2 1 1 y = 11 f = 2 4513 c = 1 y = 1 f = 2 2 2 2 3 3 5 7 43 107 c = 2 1 1 1 1 y = 47 f = 2 2 2 2 7 43 c = 1 1 y = 3 f = 3 3 5 107 c = 2 1 1 y = 11 f = 2 2 2 3 3 7 19 59 109 c = 2 1 1 1 1 y = 47 f = 2 2 2 3 3 109 c = 2 1 y = 5 f = 7 19 59 c = 1 1 1 y = 7 f = 2 3 19 61 773 c = 1 1 1 1 y = 15 f = 3 773 c = 1 1 y = 3 f = 2 19 61 c = 1 1 y = 3 f = 2 5 11 43 149 233 c = 1 1 1 1 1 y = 31 f = 5 11 233 c = 1 1 1 y = 7 f = 2 43 149 c = 1 1 y = 3 f = 2 3 3 3 11 197 967 c = 3 1 1 1 y = 31 f = 2 3 3 3 197 c = 3 1 y = 7 f = 11 967 c = 1 1 y = 3 f = 2 5 11 13 71 839 c = 1 1 1 1 1 y = 31 f = 2 5 13 71 c = 1 1 1 y = 7 f = 11 839 c = 1 1 y = 3 f = 2 3 3 11 17 61 1697 c = 2 1 1 1 1 y = 47 f = 11 1697 c = 1 1 y = 3 f = 2 3 3 17 61 c = 2 1 1 y = 11 f = 2 2 2 5 11 37 73 223 c = 1 1 1 1 1 y = 31 f = 2 2 2 5 11 37 c = 1 1 1 y = 7 f = 73 223 c = 1 1 y = 3