/*
Daniel Abraham
Thomas Jefferson
High School for Science and Technology
Junior Division
Contest #3
2010-2011
ACSL Mancala
*/
import java.util.Scanner;
public class Mancala_Abraham
{
public static void main(String[] args)
{
Scanner keyboard = new
Scanner(System.in);
System.out.println("Each line of
input should be comma seperated.\n e.g. '4,6'");
//create
and array of stones
//0-11
= holes 1-12, 12 = hole A, 13 = hole B
int gameBoard[] = new int[14];
for(int i = 0; i < gameBoard.length
- 2; i++)
gameBoard[i] = 4;
for(int turn = 1; turn <= 5;
turn++)
{
System.out.print(turn + ".
");
//get the starting hole and the hole to
report
String inputAsString[] =
(keyboard.nextLine()).split(",");
int startHole =
Integer.parseInt(inputAsString[0].trim());
int holeToReport =
Integer.parseInt(inputAsString[1].trim());
int holeToUpdate = startHole;
//take
stones from starting hole
int numOfStones =
gameBoard[startHole - 1];
gameBoard[startHole - 1] = 0;
//move
the stones until stones in hand run out
for(; numOfStones > 0;
numOfStones--)
{
switch(holeToUpdate)
{
case 6:
if(turn % 2 == 1)
holeToUpdate = 13;
else
holeToUpdate
= 7;
break;
case 12:
if(turn % 2 == 0)
holeToUpdate = 14;
else
holeToUpdate
= 1;
break;
case 13: holeToUpdate = 7;
break;
case 14: holeToUpdate = 1;
break;
default: holeToUpdate++;
}
gameBoard[holeToUpdate - 1]++;
}
//print number of stones
in hole to be reported
System.out.println("\t" +
gameBoard[holeToReport - 1]);
//used for debugging
purposes
// for(int i = 0; i <
gameBoard.length; i++)
//
System.out.print(" " + gameBoard[i]);
//
System.out.print("\n");
}
}
}