Problem 53840. Backgammon #3  Display a Board Position
 White stones are represented by positive integers Red stones represented by negative integers.
 The board is a vector of integers: The first 24 integers are the points numbered (from White's perspective) 1 to 24; integers 25 and 26 are white's bar and red's bar respectively; integers 27 and 28 are whites home and red's home respectively
 Each integer represents the number of stones on that point; e.g. 4 means white has 4 stones on that point; 2 means red has 2 stones on that point.
Solution Stats
Problem Comments

4 Comments
There are a couple problems with the tests. The "correct" result listed in test #4 has an error in it. One of the B's down the centerline in an 'X'. Also, the importdata() command used in test #5 seems to fail.
Hi @William, many thanks for attempting this problem. The result in the test suite for test 4 is correct. The Bs down the centreline represent the Bar, and that test case has one of red's stones on the bar (1 in the Board vector's 26th element), so the 'X' on the Bar is correct and represents that stone. This case is shown in the second example of the problem description, where you also see the 'X' on the Bar. As for the importdata() function, I'm not sure why that failed for you, but it must have been a Cody glitch, because it seems to work OK for me now (I submitted a dummy solution to test that case, which passed). Maybe you can try again? Regards, Mark
@William, just to follow up on the last point; I have investigated further and indeed you are correct that the importdata() function fails for your code (but not my reference solution!). I can't immediately see why this is. Test 5 was intended as an 'anticheating' test but is perhaps not needed for this problem, so I've removed test 5 for now. If others try to game the problem by cheating I'll have another think about how to block those solutions! If you can fix your code to pass test 4 then I think you'll now get a working solution. Regards, Mark
Mark, Thanks for the explanation! I have never played Backgammon, so this is a good learning opportunity for me. My modified code now passes all the tests, including an uncommented version of test #5.
Solution Comments
Show commentsProblem Recent Solvers2
Suggested Problems

4374 Solvers

1882 Solvers

8732 Solvers

657 Solvers

Remove All elements less than 5
137 Solvers
More from this Author17
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!