Last active
December 21, 2015 01:09
-
-
Save matejvelikonja/6225563 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
if (! isset($argv[1])) { | |
echo 'Usage scopa.php number' . PHP_EOL; | |
exit; | |
} | |
// offical for 3 players, 3 in hand, 4 on table | |
// r = (-i k-m+40)/(i k) | |
$totalCards = 40; | |
$minRounds = 3; | |
$minInHand = 3; | |
$minOnTable = 4; | |
$numberOfPlayers = $argv[1]; | |
if ($numberOfPlayers < 2) { | |
echo 'Number of players must be at least 2.' . PHP_EOL; | |
exit; | |
} | |
echo "Results for $numberOfPlayers players." . PHP_EOL; | |
for ($cardsOnTable = $minOnTable; $cardsOnTable < $totalCards; $cardsOnTable++) { | |
for ($cardsInHand = $minInHand; $cardsInHand < $totalCards; $cardsInHand++) { | |
$rounds = | |
(-1 * $numberOfPlayers * $cardsInHand - $cardsOnTable + $totalCards) / | |
($numberOfPlayers * $cardsInHand); | |
if (is_int($rounds) && $rounds >= $minRounds) { | |
echo "Rounds $rounds, On table: $cardsOnTable, In hand: $cardsInHand" . PHP_EOL; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment