Cody

# Problem 986. Penny Flipping: Reverse subsets of a sequence of coins until you recover the original configuration

Solution 2042165

Submitted on 2 Dec 2019 by cokakola
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
n = 1; y_correct = 2; assert(isequal(coinFlipAlt(n),y_correct))

1: 1 2: 0

2   Pass
n = 3; y_correct = 3; assert(isequal(coinFlipAlt(n),y_correct))

1: 0 0 1 2: 1 1 1 3: 0 0 0

3   Pass
n = 10; y_correct = 295; assert(isequal(coinFlipAlt(n),y_correct))

1: 0 0 0 0 0 0 0 0 0 1 2: 1 1 0 0 0 0 0 0 0 1 3: 1 1 0 0 0 0 0 0 1 1 4: 1 1 0 0 0 0 0 0 1 1 5: 1 1 0 0 0 0 0 1 1 1 6: 1 1 1 1 0 0 0 1 1 1 7: 1 1 1 0 0 0 1 1 1 0 8: 0 0 1 1 1 0 0 0 1 0 9: 0 1 0 1 1 1 0 0 0 1 10: 0 1 1 1 0 0 0 1 0 1 11: 0 1 1 1 0 0 0 1 0 0 12: 0 1 1 1 0 0 0 1 0 0 13: 0 1 1 1 0 0 0 1 1 0 14: 0 0 0 1 0 0 0 1 1 0 15: 0 0 0 1 0 1 0 0 1 1 16: 0 1 0 1 1 1 0 0 1 1 17: 0 1 0 0 0 1 1 0 0 0 18: 1 0 0 1 1 1 0 1 0 0 19: 1 1 1 0 1 0 0 0 1 1 20: 0 0 1 1 1 0 1 0 0 0 21: 0 0 1 1 1 0 1 0 0 1 22: 1 1 1 1 1 0 1 0 0 1 23: 1 1 1 1 1 0 1 0 1 1 24: 0 0 0 0 1 0 1 0 1 1 25: 0 0 0 0 1 0 0 1 0 1 26: 1 0 1 1 1 1 0 1 0 1 27: 1 0 1 0 1 0 1 0 0 0 28: 1 0 1 0 1 0 1 0 0 0 29: 1 1 1 1 0 1 0 1 0 1 30: 0 1 0 1 0 1 0 0 0 0 31: 0 1 0 1 0 1 0 0 0 1 32: 0 1 0 1 0 1 0 0 0 1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