Cody

# Problem 46. Which doors are open?

Solution 162949

Submitted on 16 Nov 2012 by Claudia
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))

doors = 1 y = 1

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

doors = 1 doors = 1 0 doors = 1 0 0 y = 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))

doors = 1 doors = 1 0 doors = 1 0 0 doors = 1 0 0 1 doors = 1 0 0 1 0 doors = 1 0 0 1 0 0 doors = 1 0 0 1 0 0 0 doors = 1 0 0 1 0 0 0 0 doors = 1 0 0 1 0 0 0 0 1 doors = 1 0 0 1 0 0 0 0 1 0 doors = 1 0 0 1 0 0 0 0 1 0 0 doors = 1 0 0 1 0 0 0 0 1 0 0 0 doors = 1 0 0 1 0 0 0 0 1 0 0 0 0 doors = 1 0 0 1 0 0 0 0 1 0 0 0 0 0 doors = 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 doors = 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 doors = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 Column 17 0 doors = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 Columns 17 through 18 0 0 doors = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 Columns 17 through 19 0 0 0 doors = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 Columns 17 through 20 0 0 0 0 doors = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 Columns 17 through 21 0 0 0 0 0 doors = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 Columns 17 through 22 0 0 0 0 0 0 doors = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 Columns 17 through 23 0 0 0 0 0 0 0 doors = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 Columns 17 through 24 0 0 0 0 0 0 0 0 doors = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 Columns 17 through 25 0 0 0 0 0 0 0 0 1 doors = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 Columns 17 through 26 0 0 0 0 0 0 0 0 1 0 doors = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 Columns 17 through 27 0 0 0 0 0 0 0 0 1 0 0 doors = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 Columns 17 through 28 0 0 0 0 0 0 0 0 1 0 0 0 doors = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 Columns 17 through 29 0 0 0 0 0 0 0 0 1 0 0 0 0 doors = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 Columns 17 through 30 0 0 0 0 0 0 0 0 1 0 0 0 0 0 doors = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 Columns 17 through 31 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 doors = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 Columns 17 through 32 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 doors = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 Columns 17 through 32 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 Column 33 0 doors = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 Columns 17 through 32 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 Columns 33 through 34 0 0 doors = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 Columns 17 through 32 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 Columns 33 through 35 0 0 0 doors = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 Columns 17 through 32 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 Columns 33 through 36 0 0 0 1 doors = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 Columns 17 through 32 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 Columns 33 through 37 0 0 0 1 0 doors = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 Columns 17 through 32 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 Columns 33 through 38 0 0 0 1 0 0 doors = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 Columns 17 through 32 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 Columns 33 through 39 0 0 0 1 0 0 0 doors = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 Columns 17 through 32 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 Columns 33 through 40 0 0 0 1 0 0 0 0 doors = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 Columns 17 through 32 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 Columns 33 through 41 0 0 0 1 0 0 0 0 0 doors = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 Columns 17 through 32 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 Columns 33 through 42 0 0 0 1 0 0 0 0 0 0 doors = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 Columns 17 through 32 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 Columns 33 through 43 0 0 0 1 0 0 0 0 0 0 0 doors = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 Columns 17 through 32 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 Columns 33 through 44 0 0 0 1 0 0 0 0 0 0 0 0 doors = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 Columns 17 through 32 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 Columns 33 through 45 0 0 0 1 0 0 0 0 0 0 0 0 0 doors = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 Columns 17 through 32 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 Columns 33 through 46 0 0 0 1 0 0 0 0 0 0 0 0 0 0 doors = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 Columns 17 through 32 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 Columns 33 through 47 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 doors = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 Columns 17 through 32 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 Columns 33 through 48 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 doors = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 Columns 17 through 32 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 Columns 33 through 48 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Column 49 1 doors = Columns 1 through 16 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 Columns 17 through 32 0 0 0 0 0 0 0 0 1 ...

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!