Cody

# Problem 2595. Polite numbers. Politeness.

Solution 1936571

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 = 0

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

f = 2 ff = 2 cnt = 1 ans = 0

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

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

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

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

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

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

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

f = 3 5 ff = 3 5 cnt = 1 1 ans = 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

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

f = 3 7 ff = 3 7 cnt = 1 1 ans = 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 = 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 = 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 = 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

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

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

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

f = 5 13 ff = 5 13 cnt = 1 1 ans = 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 89 ff = 2 89 cnt = 3 1 ans = 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 13 19 41 61 83 ff = 2 13 19 41 61 83 cnt = 1 1 1 1 1 1 ans = 31 f = 13 19 41 ff = 13 19 41 cnt = 1 1 1 ans = 7 f = 2 61 83 ff = 2 61 83 cnt = 1 1 1 ans = 3 f = 2 13 73 229 643 ff = 2 13 73 229 643 cnt = 1 1 1 1 1 ans = 15 f = 2 13 643 ff = 2 13 643 cnt = 1 1 1 ans = 3 f = 73 229 ff = 73 229 cnt = 1 1 ans = 3 f = 2 5 7 61 4271 ff = 2 5 7 61 4271 cnt = 1 1 1 1 1 ans = 15 f = 4271 ff = 4271 cnt = 1 ans = 1 f = 2 5 7 61 ff = 2 5 7 61 cnt = 1 1 1 1 ans = 7 f = 2 3 3 2087 9391 ff = 2 3 2087 9391 cnt = 1 2 1 1 ans = 11 f = 3 3 2087 ff = 3 2087 cnt = 2 1 ans = 5 f = 2 9391 ff = 2 9391 cnt = 1 1 ans = 1 f = 2 11 1283 7057 ff = 2 11 1283 7057 cnt = 1 1 1 1 ans = 7 f = 2 7057 ff = 2 7057 cnt = 1 1 ans = 1 f = 11 1283 ff = 11 1283 cnt = 1 1 ans = 3 f = 2 3 3 23 59 61 107 ff = 2 3 23 59 61 107 cnt = 1 2 1 1 1 1 ans = 47 f = 3 3 23 61 ff = 3 23 61 cnt = 2 1 1 ans = 11 f = 2 59 107 ff = 2 59 107 cnt = 1 1 1 ans = 3 f = 2 11 23 127 ff = 2 11 23 127 cnt = 1 1 1 1 ans = 7 f = 2 127 ff = 2 127 cnt = 1 1 ans = 1 f = 11 23 ff = 11 23 cnt = 1 1 ans = 3 f = 2 2 2 3 3 3 3 5 37 1873 ff = 2 3 5 37 1873 cnt = 3 4 1 1 1 ans = 39 f = 3 3 3 3 5 37 ff = 3 5 37 cnt = 4 1 1 ans = 19 f = 2 2 2 1873 ff = 2 1873 cnt = 3 1 ans = 1 f = 2 2 3 1831 2441 ff = 2 3 1831 2441 cnt = 2 1 1 1 ans = 7 f = 2 2 1831 ff = 2 1831 cnt = 2 1 ans = 1 f = 3 2441 ff = 3 2441 cnt = 1 1 ans = 3 f = 2 2 2 3 23 107 6563 ff = 2 3 23 107 6563 cnt = 3 1 1 1 1 ans = 15 f = 3 6563 ff = 3 6563 cnt = 1 1 ans = 3 f = 2 2 2 23 107 ff = 2 23 107 cnt = 3 1 1 ans = 3 f = 2 2 3 5 11 19 12541 ff = 2 3 5 11 19 12541 cnt = 2 1 1 1 1 1 ans = 31 f = 12541 ff = 12541 cnt = 1 ans = 1 f = 2 2 3 5 11 19 ff = 2 3 5 11 19 cnt = 2 1 1 1 1 ans = 15 f = 2 17 881 7489 ff = 2 17 881 7489 cnt = 1 1 1 1 ans = 7 f = 2 7489 ff = 2 7489 cnt = 1 1 ans = 1 f = 17 881 ff = 17 881 cnt = 1 1 ans = 3 f = 2 2 2 2 3 19 59 149 ff = 2 3 19 59 149 cnt = 4 1 1 1 1 ans = 15 f = 2 2 2 2 3 59 ff = 2 3 59 cnt = 4 1 1 ans = 3 f = 19 149 ff = 19 149 cnt = 1 1 ans = 3 f = 2 7 19 61 331 ff = 2 7 19 61 331 cnt = 1 1 1 1 1 ans = 15 f = 2 19 61 ff = 2 19 61 cnt = 1 1 1 ans = 3 f = 7 331 ff = 7 331 cnt = 1 1 ans = 3 f = 2 2 3 17 251 5689 ff = 2 3 17 251 5689 cnt = 2 1 1 1 1 ans = 15 f = 2 2 17 251 ff = 2 17 251 cnt = 2 1 1 ans = 3 f = 3 5689 ff = 3 5689 cnt = 1 1 ans = 3 f = 2 2 3 3 5 257 571 ff = 2 3 5 257 571 cnt = 2 2 1 1 1 ans = 23 f = 2 2 5 257 ff = 2 5 257 cnt = 2 1 1 ans = 3 f = 3 3 571 ff = 3 571 cnt = 2 1 ans = 5 f = 2 3 3 7 7 19 16759 ff = 2 3 7 19 16759 cnt = 1 2 2 1 1 ans = 35 f = 16759 ff = 16759 cnt = 1 ans = 1 f = 2 3 3 7 7 19 ff = 2 3 7 19 cnt = 1 2 2 1 ans = 17 f = 2 2 2 2 2 2 13 79 389 ff = 2 13 79 389 cnt = 6 1 1 1 ans = 7 f = 13 389 ff = 13 389 cnt = 1 1 ans = 3 f = 2 2 2 2 2 2 79 ff = 2 79 cnt = 6 1 ans = 1 f = 2 2 19 181 13757 ff = 2 19 181 13757 cnt = 2 1 1 1 ans = 7 f = 13757 ff = 13757 cnt = 1 ans = 1 f = 2 2 19 181 ff = 2 19 181 cnt = 2 1 1 ans = 3 f = 2 5 7 7 359 1759 ff = 2 5 7 359 1759 cnt = 1 1 2 1 1 ans = 23 f = 7 7 359 ff = 7 359 cnt = 2 1 ans = 5 f = 2 5 1759 ff = 2 5 1759 cnt = 1 1 1 ans = 3