6, 'score' => 0]; $playerB = ['position' => 4, 'score' => 0]; $totalDiceRolls = 0; while (max([$playerA['score'], $playerB['score']]) < 1000) { $rolls = 0; $rolls += ++$totalDiceRolls; $rolls += ++$totalDiceRolls; $rolls += ++$totalDiceRolls; $playerScore = ($playerA['position'] + $rolls) % 10; if (($playerA['position'] + $rolls) % 10 === 0) { $playerScore = 10; } $playerA['position'] = $playerScore; $playerA['score'] += $playerScore; if ($playerA['score'] >= 1000) { break; } $rolls = 0; $rolls += ++$totalDiceRolls; $rolls += ++$totalDiceRolls; $rolls += ++$totalDiceRolls; $playerScore = ($playerB['position'] + $rolls) % 10; if (($playerB['position'] + $rolls) % 10 === 0) { $playerScore = 10; } $playerB['position'] = $playerScore; $playerB['score'] += $playerScore; } echo min([$playerA['score'], $playerB['score']]) * $totalDiceRolls; //920580