Cody

# Problem 391. Poker Series 11: selectBestHand

Solution 1952311

Submitted on 28 Sep 2019
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   Fail
hm1 = [0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; om1 = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; hm2 = [0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; om2 = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; out.hm{1} = om1; out.hm{2} = om2; out.winner = 0; assert(isequal(selectBestHand(hm1,hm2),out))

X = 1×2 cell array {1×1 struct} {1×1 struct} X = 1×2 cell array {1×1 struct} {1×1 struct} out = struct with fields: hm: {[4×13 logical] [4×13 logical]} winner: [0×1 double]

Assertion failed.

2   Fail
hm1 = [0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; om1 = [0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; hm2 = [0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; om2 = [0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; out.hm{1} = om1; out.hm{2} = om2; out.winner = 2; assert(isequal(selectBestHand(hm1,hm2),out))

out = struct with fields: flag: 1 usedCards: [4×13 logical] out = struct with fields: flag: 1 usedCards: [4×13 logical] sc1 = logical 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 out = struct with fields: flag: 1 usedCards: [4×13 logical] out = struct with fields: flag: 1 usedCards: [4×13 logical] out = struct with fields: flag: 1 usedCards: [4×13 logical] sc1 = logical 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 out = struct with fields: hm: {[4×13 logical] [4×13 logical]} winner: 1

Assertion failed.

3   Fail
hm1 = [0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0]; om1 = [0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0]; hm2 = [0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0]; om2 = [0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; out.hm{1} = om1; out.hm{2} = om2; out.winner = 1; assert(isequal(selectBestHand(hm1,hm2),out))

out = struct with fields: flag: 1 usedCards: [4×13 logical] out = struct with fields: flag: 1 usedCards: [4×13 logical] sc1 = logical 0 out = struct with fields: flag: 1 usedCards: [4×13 logical] rest = 4 13 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 out = struct with fields: flag: 1 usedCards: [4×13 logical] out = struct with fields: flag: 1 usedCards: [4×13 logical] out = struct with fields: flag: 1 usedCards: [4×13 logical] sc1 = logical 0 out = struct with fields: flag: 1 usedCards: [4×13 logical] 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 out = struct with fields: hm: {[4×13 logical] [4×13 logical]} winner: 2

Assertion failed.

4   Pass
hm1 = [0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0]; om1 = [0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0]; hm2 = [0 1 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0]; om2 = [0 1 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0]; out.hm{1} = om1; out.hm{2} = om2; out.winner = 1; assert(isequal(selectBestHand(hm1,hm2),out))

out = struct with fields: flag: 1 usedCards: [4×13 logical] out = struct with fields: flag: 1 usedCards: [4×13 logical] sc1 = logical 0 out = struct with fields: flag: 1 usedCards: [4×13 logical] rest = 4 13 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 out = struct with fields: flag: 1 usedCards: [4×13 logical] out = struct with fields: flag: 1 usedCards: [4×13 logical] sc1 = logical 0 rest = 12 0 1 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 X = 1×2 cell array {1×1 struct} {1×1 struct} X = 1×2 cell array {1×1 struct} {1×1 struct} out = struct with fields: hm: {[4×13 logical] [4×13 logical]} winner: 1

5   Fail
hm1 = [0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0]; om1 = [0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0]; hm2 = [0 1 0 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0]; om2 = [0 1 0 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; out.hm{1} = om1; out.hm{2} = om2; out.winner = 1; assert(isequal(selectBestHand(hm1,hm2),out))

out = struct with fields: flag: 1 usedCards: [4×13 logical] out = struct with fields: flag: 1 usedCards: [4×13 logical] out = struct with fields: flag: 1 usedCards: [4×13 logical] sc1 = logical 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 out = struct with fields: flag: 1 usedCards: [4×13 logical] out = struct with fields: flag: 1 usedCards: [4×13 logical] out = struct with fields: flag: 1 usedCards: [4×13 logical] sc1 = logical 0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 X = 1×2 cell array {1×1 struct} {1×1 struct} X = 1×2 cell array {1×1 struct} {1×1 struct} out = struct with fields: hm: {[4×13 logical] [4×13 logical]} winner: 0

Assertion failed.

6   Fail
hm1 = [1 1 1 1 1 0 0 0 0 0 0 0 1 0 1 0 0 1 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0]; om1 = [1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; hm2 = [0 1 0 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0]; om2 = [0 1 0 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; out.hm{1} = om1; out.hm{2} = om2; out.winner = 1; assert(isequal(selectBestHand(hm1,hm2),out))

out = struct with fields: flag: 1 usedCards: [4×13 logical] out = struct with fields: flag: 1 usedCards: [4×13 logical] out = struct with fields: flag: 1 usedCards: [4×13 logical] sc1 = logical 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 out = struct with fields: flag: 1 usedCards: [4×13 logical] out = struct with fields: flag: 1 usedCards: [4×13 logical] out = struct with fields: flag: 1 usedCards: [4×13 logical] sc1 = logical 0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 out = struct with fields: hm: {[4×13 logical] [4×13 logical]} winner: 2

Assertion failed.

7   Pass
hm1 = [1 1 1 1 1 0 0 0 0 0 0 0 1 0 1 0 0 1 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0]; om1 = [1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; hm2 = [1 1 1 1 1 1 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0]; om2 = [0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; out.hm{1} = om1; out.hm{2} = om2; out.winner = 2; assert(isequal(selectBestHand(hm1,hm2),out))

out = struct with fields: flag: 1 usedCards: [4×13 logical] out = struct with fields: flag: 1 usedCards: [4×13 logical] out = struct with fields: flag: 1 usedCards: [4×13 logical] sc1 = logical 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 out = struct with fields: flag: 1 usedCards: [4×13 logical] out = struct with fields: flag: 1 usedCards: [4×13 logical] out = struct with fields: flag: 1 usedCards: [4×13 logical] sc1 = logical 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 X = 1×2 cell array {1×1 struct} {1×1 struct} X = 1×2 cell array {1×1 struct} {1×1 struct} out = struct with fields: hm: {[4×13 logical] [4×13 logical]} winner: 2

8   Fail
hm1 = [0 1 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; om1 = [0 1 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; hm2 = [0 0 0 0 1 1 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0]; om2 = [0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0]; out.hm{1} = om1; out.hm{2} = om2; out.winner = 2; assert(isequal(selectBestHand(hm1,hm2),out))

out = struct with fields: flag: 1 usedCards: [4×13 logical] out = struct with fields: flag: 1 usedCards: [4×13 logical] out = struct with fields: flag: 1 usedCards: [4×13 logical] sc1 = logical 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 out = struct with fields: flag: 1 usedCards: [4×13 logical] out = struct with fields: flag: 1 usedCards: [4×13 logical] out = struct with fields: flag: 1 usedCards: [4×13 logical] sc1 = logical 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 X = 1×2 cell array {1×1 struct} {1×1 struct} X = 1×2 cell array {1×1 struct} {1×1 struct} out = struct with fields: hm: {[4×13 logical] [4×13 logical]} winner: 0

Assertion failed.

9   Fail
hm1 = [0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0]; om1 = [0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0]; hm2 = [0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0]; om2 = [0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; out.hm{1} = om1; out.hm{2} = om2; out.winner = 2; assert(isequal(selectBestHand(hm1,hm2),out))

out = struct with fields: flag: 1 usedCards: [4×13 logical] out = struct with fields: flag: 1 usedCards: [4×13 logical] out = struct with fields: flag: 1 usedCards: [4×13 logical] sc1 = logical 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 out = struct with fields: flag: 1 usedCards: [4×13 logical] out = struct with fields: flag: 1 usedCards: [4×13 logical] out = struct with fields: flag: 1 usedCards: [4×13 logical] sc1 = logical 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 X = 1×2 cell array {1×1 struct} {1×1 struct} X = 1×2 cell array {1×1 struct} {1×1 struct} out = struct with fields: hm: {[4×13 logical] [4×13 logical]} winner: 0

Assertion failed.