Cody

# Problem 46. Which doors are open?

Solution 582717

Submitted on 15 Feb 2015 by Riyasat
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 = 1; assert(isequal(which_doors_open(x),y_correct))

a = 1 f = 1 idx = 1

2   Pass
%% x = 3; y_correct = 1; assert(isequal(which_doors_open(x),y_correct))

a = 1 1 1 a = 1 0 1 a = 1 0 0 f = 1 idx = 1

3   Pass
%% x = 100; y_correct = [1 4 9 16 25 36 49 64 81 100]; assert(isequal(which_doors_open(x),y_correct))

a = Columns 1 through 16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 17 through 32 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 33 through 48 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 49 through 64 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 65 through 80 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 81 through 96 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 97 through 100 1 1 1 1 a = Columns 1 through 16 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 Columns 17 through 32 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 Columns 33 through 48 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 Columns 49 through 64 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 Columns 65 through 80 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 Columns 81 through 96 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 Columns 97 through 100 1 0 1 0 a = Columns 1 through 16 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 Columns 17 through 32 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 Columns 33 through 48 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 Columns 49 through 64 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 Columns 65 through 80 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 Columns 81 through 96 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 Columns 97 through 100 1 0 0 0 a = Columns 1 through 16 1 0 0 1 1 1 1 1 0 0 1 0 1 0 0 1 Columns 17 through 32 1 1 1 1 0 0 1 0 1 0 0 1 1 1 1 1 Columns 33 through 48 0 0 1 0 1 0 0 1 1 1 1 1 0 0 1 0 Columns 49 through 64 1 0 0 1 1 1 1 1 0 0 1 0 1 0 0 1 Columns 65 through 80 1 1 1 1 0 0 1 0 1 0 0 1 1 1 1 1 Columns 81 through 96 0 0 1 0 1 0 0 1 1 1 1 1 0 0 1 0 Columns 97 through 100 1 0 0 1 a = Columns 1 through 16 1 0 0 1 0 1 1 1 0 1 1 0 1 0 1 1 Columns 17 through 32 1 1 1 0 0 0 1 0 0 0 0 1 1 0 1 1 Columns 33 through 48 0 0 0 0 1 0 0 0 1 1 1 1 1 0 1 0 Columns 49 through 64 1 1 0 1 1 1 0 1 0 0 1 1 1 0 0 1 Columns 65 through 80 0 1 1 1 0 1 1 0 1 0 1 1 1 1 1 0 Columns 81 through 96 0 0 1 0 0 0 0 1 1 0 1 1 0 0 0 0 Columns 97 through 100 1 0 0 0 a = Columns 1 through 16 1 0 0 1 0 0 1 1 0 1 1 1 1 0 1 1 Columns 17 through 32 1 0 1 0 0 0 1 1 0 0 0 1 1 1 1 1 Columns 33 through 48 0 0 0 1 1 0 0 0 1 0 1 1 1 0 1 1 Columns 49 through 64 1 1 0 1 1 0 0 1 0 0 1 0 1 0 0 1 Columns 65 through 80 0 0 1 1 0 1 1 1 1 0 1 1 1 0 1 0 Columns 81 through 96 0 0 1 1 0 0 0 1 1 1 1 1 0 0 0 1 Columns 97 through 100 1 0 0 0 a = Columns 1 through 16 1 0 0 1 0 0 0 1 0 1 1 1 1 1 1 1 Columns 17 through 32 1 0 1 0 1 0 1 1 0 0 0 0 1 1 1 1 Columns 33 through 48 0 0 1 1 1 0 0 0 1 1 1 1 1 0 1 1 Columns 49 through 64 0 1 0 1 1 0 0 0 0 0 1 0 1 0 1 1 Columns 65 through 80 0 0 1 1 0 0 1 1 1 0 1 1 0 0 1 0 Columns 81 through 96 0 0 1 0 0 0 0 1 1 1 0 1 0 0 0 1 Columns 97 through 100 1 1 0 0 a = Columns 1 through 16 1 0 0 1 0 0 0 0 0 1 1 1 1 1 1 0 Columns 17 through 32 1 0 1 0 1 0 1 0 0 0 0 0 1 1 1 0 Columns 33 through 48 0 0 1 1 1 0 0 1 1 1 1 1 1 0 1 0 Columns 49 through 64 0 1 0 1 1 0 0 1 0 0 1 0 1 0 1 0 Columns 65 through 80 0 0 1 1 0 0 1 0 1 0 1 1 0 0 1 1 Columns 81 through 96 0 0 1 0 0 0 0 0 1 1 0 1 0 0 0 0 Columns 97 through 100 1 1 0 0 a = Columns 1 through 16 1 0 0 1 0 0 0 0 1 1 1 1 1 1 1 0 Columns 17 through 32 1 1 1 0 1 0 1 0 0 0 1 0 1 1 1 0 Columns 33 through 48 0 0 1 0 1 0 0 1 1 1 1 1 0 0 1 0 Columns 49 through 64 0 1 0 1 1 1 0 1 0 0 1 0 1 0 0 0 Columns 65 through 80 0 0 1 1 0 0 1 1 1 0 1 1 0 0 1 1 Columns 81 through 96 1 0 1 0 0 0 0 0 1 0 0 1 0 0 0 0 Columns 97 through 100 1 1 1 0 a = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 1 1 1 1 1 0 Columns 17 through 32 1 1 1 1 1 0 1 0 0 0 1 0 1 0 1 0 Columns 33 through 48 0 0 1 0 1 0 0 0 1 1 1 1 0 0 1 0 Columns 49 through 64 0 0 0 1 1 1 0 1 0 0 1 1 1 0 0 0 Columns 65 through 80 0 0 1 1 0 1 1 1 1 0 1 1 0 0 1 0 Columns 81 through 96 1 0 1 0 0 0 0 0 1 1 0 1 0 0 0 0 Columns 97 through 100 1 1 1 1 a = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 1 1 1 1 0 Columns 17 through 32 1 1 1 1 1 1 1 0 0 0 1 0 1 0 1 0 Columns 33 through 48 1 0 1 0 1 0 0 0 1 1 1 0 0 0 1 0 Columns 49 through 64 0 0 0 1 1 1 1 1 0 0 1 1 1 0 0 0 Columns 65 through 80 0 1 1 1 0 1 1 1 1 0 1 1 1 0 1 0 Columns 81 through 96 1 0 1 0 0 0 0 1 1 1 0 1 0 0 0 0 Columns 97 through 100 1 1 0 1 a = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 1 1 1 0 Columns 17 through 32 1 1 1 1 1 1 1 1 0 0 1 0 1 0 1 0 Columns 33 through 48 1 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 Columns 49 through 64 0 0 0 1 1 1 1 1 0 0 1 0 1 0 0 0 Columns 65 through 80 0 1 1 1 0 1 1 0 1 0 1 1 1 0 1 0 Columns 81 through 96 1 0 1 1 0 0 0 1 1 1 0 1 0 0 0 1 Columns 97 through 100 1 1 0 1 a = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 1 1 0 Columns 17 through 32 1 1 1 1 1 1 1 1 0 1 1 0 1 0 1 0 Columns 33 through 48 1 0 1 1 1 0 1 0 1 1 1 0 0 0 1 1 Columns 49 through 64 0 0 0 0 1 1 1 1 0 0 1 0 1 0 0 0 Columns 65 through 80 1 1 1 1 0 1 1 0 1 0 1 1 1 1 1 0 Columns 81 through 96 1 0 1 ...