Cody

Solution 1832610

Submitted on 31 May 2019 by John Walker
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
assert(isequal(one_hot(1,1),1))

ans = logical 1

2   Pass
assert(isequal(one_hot(2,1),[1 0]))

ans = 1×2 logical array 1 0

3   Pass
assert(isequal(one_hot(3,3),[0 0 1]))

ans = 1×3 logical array 0 0 1

4   Pass
assert(isequal(one_hot(4,1),[1 0 0 0]))

ans = 1×4 logical array 1 0 0 0

5   Pass
assert(isequal(one_hot(5,2),[0 1 0 0 0]))

ans = 1×5 logical array 0 1 0 0 0

6   Pass
assert(isequal(one_hot(6,1),[1 0 0 0 0 0]))

ans = 1×6 logical array 1 0 0 0 0 0

7   Pass
assert(isequal(one_hot(7,1),[1 0 0 0 0 0 0]))

ans = 1×7 logical array 1 0 0 0 0 0 0

8   Pass
assert(isequal(one_hot(8,7),[0 0 0 0 0 0 1 0]))

ans = 1×8 logical array 0 0 0 0 0 0 1 0

9   Pass
assert(isequal(one_hot(9,7),[0 0 0 0 0 0 1 0 0]))

ans = 1×9 logical array 0 0 0 0 0 0 1 0 0

10   Pass
assert(isequal(one_hot(10,4),[0 0 0 1 0 0 0 0 0 0]))

ans = 1×10 logical array 0 0 0 1 0 0 0 0 0 0

11   Pass
assert(isequal(one_hot(11,11),[0 0 0 0 0 0 0 0 0 0 1]))

ans = 1×11 logical array 0 0 0 0 0 0 0 0 0 0 1

12   Pass
assert(isequal(one_hot(12,1),[1 0 0 0 0 0 0 0 0 0 0 0]))

ans = 1×12 logical array 1 0 0 0 0 0 0 0 0 0 0 0

13   Pass
assert(isequal(one_hot(13,6),[0 0 0 0 0 1 0 0 0 0 0 0 0]))

ans = 1×13 logical array 0 0 0 0 0 1 0 0 0 0 0 0 0

14   Pass
assert(isequal(one_hot(14,6),[0 0 0 0 0 1 0 0 0 0 0 0 0 0]))

ans = 1×14 logical array 0 0 0 0 0 1 0 0 0 0 0 0 0 0

15   Pass
assert(isequal(one_hot(15,12),[0 0 0 0 0 0 0 0 0 0 0 1 0 0 0]))

ans = 1×15 logical array 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0

16   Pass
assert(isequal(one_hot(16,13),[0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0]))

ans = 1×16 logical array 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0

17   Pass
assert(isequal(one_hot(17,4),[0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0]))

ans = 1×17 logical array 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0

18   Pass
assert(isequal(one_hot(18,9),[0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0]))

ans = 1×18 logical array 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0

19   Pass
assert(isequal(one_hot(19,9),[0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0]))

ans = 1×19 logical array 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0

20   Pass
assert(isequal(one_hot(20,13),[0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0]))

ans = 1×20 logical array 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0

Suggested Problems

More from this Author57