diff --git a/Retos/Reto #6 - PIEDRA, PAPEL, TIJERA, LAGARTO, SPOCK [Media]/php/kodenook.php b/Retos/Reto #6 - PIEDRA, PAPEL, TIJERA, LAGARTO, SPOCK [Media]/php/kodenook.php new file mode 100644 index 0000000000..1d326e4171 --- /dev/null +++ b/Retos/Reto #6 - PIEDRA, PAPEL, TIJERA, LAGARTO, SPOCK [Media]/php/kodenook.php @@ -0,0 +1,47 @@ + ["✂️", "🦎"], + "📄" => ["🗿", "🖖"], + "✂️" => ["📄", "🦎"], + "🦎" => ["📄", "🖖"], + "🖖" => ["🗿", "✂️"] + ]; + + $p1 = 0; + $p2 = 0; + + + foreach ($games as $game) { + if ($game[0] !== $game[1]) { + if (in_array($game[1], $rules[$game[0]])) $p1++; + else $p2++; + } + } + + if ($p1 === $p2) return 'Tie' . PHP_EOL; + elseif ($p1 > $p2) return 'Player 1' . PHP_EOL; + else return 'Player 2' . PHP_EOL; +} + +echo winnerPPTLS([["✂️", "✂️"]]); +echo winnerPPTLS([["✂️", "📄"]]); +echo winnerPPTLS([["🖖", "📄"]]); +echo winnerPPTLS([["🖖", "🗿"]]); +echo winnerPPTLS([["🖖", "🗿"], ["✂️", "🗿"], ["📄", "✂️"]]);