Cody

# Problem 46. Which doors are open?

Solution 267740

Submitted on 26 Jun 2013 by Preeyanka
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))

indices = 1 doors = 1

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

indices = 1 2 3 doors = 1 1 1 indices = 2 doors = 1 0 1 indices = 3 doors = 1 0 0

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

indices = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 32 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 Columns 33 through 48 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 Columns 49 through 64 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 Columns 65 through 80 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 Columns 81 through 96 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 Columns 97 through 100 97 98 99 100 doors = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 indices = Columns 1 through 16 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 Columns 17 through 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 Columns 33 through 48 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 Columns 49 through 50 98 100 doors = 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 indices = Columns 1 through 16 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 Columns 17 through 32 51 54 57 60 63 66 69 72 75 78 81 84 87 90 93 96 Column 33 99 doors = 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 indices = Columns 1 through 16 4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 Columns 17 through 25 68 72 76 80 84 88 92 96 100 doors = 1 0 0 1 1 1 1 1 0 0 1 0 1 0 0 1 1 1 1 1 0 0 1 0 1 0 0 1 1 1 1 1 0 0 1 0 1 0 0 1 1 1 1 1 0 0 1 0 1 0 0 1 1 1 1 1 0 0 1 0 1 0 0 1 1 1 1 1 0 0 1 0 1 0 0 1 1 1 1 1 0 0 1 0 1 0 0 1 1 1 1 1 0 0 1 0 1 0 0 1 indices = Columns 1 through 16 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 Columns 17 through 20 85 90 95 100 doors = 1 0 0 1 0 1 1 1 0 1 1 0 1 0 1 1 1 1 1 0 0 0 1 0 0 0 0 1 1 0 1 1 0 0 0 0 1 0 0 0 1 1 1 1 1 0 1 0 1 1 0 1 1 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 0 1 0 1 1 1 1 1 0 0 0 1 0 0 0 0 1 1 0 1 1 0 0 0 0 1 0 0 0 indices = 6 12 18 24 30 36 42 48 54 60 66 72 78 84 90 96 doors = 1 0 0 1 0 0 1 1 0 1 1 1 1 0 1 1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