3v4l.org

run code in 300+ PHP versions simultaneously
<?php function sortCardsBySortOrder(Array $cards, $reverse = false): Array { $changeAce = false; if (isLowStraight($cards)) { $reverse = true; $changeAce = true; } $cards = sortCards($cards, $reverse); if ($changeAce) { $ace = array_pop($cards); //rebuild the array with ace first $tmpArr = []; $tmpArr['A'.$ace['suite']] = $ace; foreach ($cards as $card => $details) { $tmpArr[$card] = $details; } $cards = $tmpArr; } return $cards; } function sortCards(Array $cards, $reverse = false): Array { uasort($cards, function($a, $b) use($reverse) { $result = $a['sort'] <=> $b['sort']; if (!$reverse) { $result *= -1; } if ($result == 0) { $result = $a['suite'] <=> $b['suite']; } return $result; }); return $cards; } function sortCardsBySuite(Array $cards, $reverse = false): Array { uasort($cards, function($a, $b) use($reverse) { $result = $a['suite'] <=> $b['suite']; if ($result == 0) { $result = $a['sort'] <=> $b['sort']; } if (!$reverse) { $result *= -1; } return $result; }); return $cards; } function shuffleCards(Array $cards): Array { $shuffled = []; while ($cards) { $key = array_rand($cards); $shuffled[$key] = $cards[$key]; unset($cards[$key]); } return $shuffled; } function dealCards(Array $cards, $num = 1) { $result = [null, null]; for ($i = 0; $i < $num; $i++) { $key = array_rand($cards); $result[1][$key] = $cards[$key]; unset($cards[$key]); } $result[0] = $cards; return $result; } function getLargestSuite(Array $cards): Array { $result = []; $lastSuite = ""; $streak = []; foreach ($cards as $card => $details) { $suite = $details['suite']; if ($suite != $lastSuite) { $lastSuite = $suite; } $streak[$suite][$card] = [$card => $details]; } uasort($streak, function ($a, $b) { $result = count($a) <=> count($b); if ($result == 0) { $a = array_map(function ($v) { $s = 0; foreach($v as $x) { $s += $x['sort']; } return $s; }, $a); $b = array_map(function ($v) { $s = 0; foreach($v as $x) { $s += $x['sort']; } return $s; }, $b); $result = array_sum($a) <=> array_sum($b); } return $result; }); return array_pop($streak); } function getLargestSet(Array $cards): Array { $result = []; $lastType = ""; $streak = []; foreach ($cards as $card => $details) { $type = substr($card, 0, 1); if ($type != $lastType) { $lastType = $type; } $streak[$type][$card] = [$card => $details]; } uasort($streak, function ($a, $b) { $result = count($a) <=> count($b); return $result; }); return array_pop($streak); } function groupBySet(Array $cards): Array { $result = []; $lastType = ""; $streak = []; $cards = sortCardsBySortOrder($cards); foreach ($cards as $card => $details) { $type = substr($card, 0, 1); if ($type != $lastType) { $lastType = $type; } $streak[$type][$card] = [$card => $details]; } uasort($streak, function ($a, $b) { $result = count($a) <=> count($b); return $result * -1; }); $cards = []; foreach ($streak as $streaks) { foreach($streaks as $card => $details) { $cards[$card] = reset($details); } } return $cards; } function isStraightFlush(Array $cards): bool { // straight flush return isStraight($cards) && isFlush($cards); } function isQuads(Array $cards): bool { // quads $hand = sortCardsBySortOrder($cards); $hand = getLargestSet($hand); return count($hand) == 4; } function isFullHouse(Array $cards): bool { // full house return isPair($cards) && isTrips($cards); } function isFlush(Array $cards) { // flush $hand = sortCardsBySortOrder($cards); $hand = sortCardsBySuite($hand); $largest = getLargestSuite($cards); if (count($largest) == 5) { return true; } return false; } function isLowStraight(Array $cards): bool { // Check for special case where Ace is low $cards = sortCards($cards, true); $lowStraight = ["2", "3", "4", "5", "A"]; $tmpArr = []; $hasAce = false; // check if ace is there foreach ($cards as $card => $details) { if (substr($card, 0, 1) === "A") { $hasAce = true; } } if ($hasAce) { $tmpArr[] = "A"; } foreach (array_slice($cards, 0, 4) as $card => $details) { $tmpArr[] = substr($card, 0, 1); } sort($tmpArr); if ($tmpArr === $lowStraight) { return true; } return false; } function isStraight(Array $cards) { // straight $hand = sortCards($cards); $h = array_slice($hand, 0, 5); foreach (traverseCardsByTwo($h) as [$card1, $card2]) { if ($card2) { $delta = $card1['sort'] - $card2['sort']; if ($delta !== 1) { if (isLowStraight($hand)) { return true; } return false; } } } return true; } function isTrips(Array $cards): bool { // trips $hand = sortCardsBySortOrder($cards); $hand = getLargestSet($hand); return count($hand) == 3; } function isTwoPair(Array $cards): bool { // pair $result = []; $lastType = ""; $streak = []; $pairs = 0; foreach ($cards as $card => $details) { $type = substr($card, 0, 1); if ($type != $lastType) { $lastType = $type; } $streak[$type][$card] = [$card => $details]; } uasort($streak, function ($a, $b) { $result = count($a) <=> count($b); return $result * -1; }); foreach($streak as $s) { if (count($s) == 2) { $pairs++; } } return $pairs >= 2; } function isPair(Array $cards): bool { // pair $result = []; $lastType = ""; $streak = []; foreach ($cards as $card => $details) { $type = substr($card, 0, 1); if ($type != $lastType) { $lastType = $type; } $streak[$type][$card] = [$card => $details]; } uasort($streak, function ($a, $b) { $result = count($a) <=> count($b); return $result * -1; }); foreach($streak as $s) { if (count($s) == 2) { return true; } } return false; } function traverseCardsByTwo(Array $cards) { reset($cards); while(key($cards) !== null) { $card1 = current($cards); $card2 = next($cards); yield [$card1, $card2]; } } function getCardsAsString(Array $cards): String { $s = []; foreach ($cards as $card => $details) { $s[] = $card; } return implode(",", $s); } function combineHands(Array $hand1, Array $hand2): Array { foreach ($hand2 as $card => $details) { $hand1[$card] = $details; } return $hand1; } function DetermineHand($board, $player) { $hand = combineHands($board, $player); $taxonomies = [ "Straight Flush" => ["Straight Flush" => 9], "Quads" => ["Quads" => 8], "Full House" => ["Full House" => 7], "Flush" => ["Flush" => 6], "Straight" => ["Straight" => 5], "Trips" => ["Trips" => 4], "Two Pair" => ["Two Pair" => 3], "Pair" => ["Pair" => 2], "High Card" => ["High Card" => 1], ]; $h = sortCardsBySortOrder($hand); if (isStraightFlush($h)) { $h = getLargestSuite($h); $h = array_slice($h, 0, 5); $handResult = ["t" => $taxonomies["Straight Flush"], "h" => $h]; } elseif (isQuads($h)) { $h = groupBySet($h); $h = array_slice($h, 0, 5); $handResult = ["t" => $taxonomies["Quads"], "h" => $h]; } elseif (isFullHouse($h)) { $h = groupBySet($h); $h = array_slice($h, 0, 5); $handResult = ["t" => $taxonomies["Full House"], "h" => $h]; } elseif (isFlush($h)) { $h = getLargestSuite($h); $h = array_slice($h, 0, 5); $handResult = ["t" => $taxonomies["Flush"], "h" => $h]; } elseif (isStraight($h)) { $handResult = ["t" => $taxonomies["Straight"], "h" => $h]; } elseif (isTrips($h)) { $h = groupBySet($h); $h = array_slice($h, 0, 5); $handResult = ["t" => $taxonomies["Trips"], "h" => $h]; } elseif (isTwoPair($h)) { $h = groupBySet($h); $h = array_slice($h, 0, 5); $handResult = ["t" => $taxonomies["Two Pair"], "h" => $h]; } elseif (isPair($h)) { $h = groupBySet($h); $h = array_slice($h, 0, 5); $handResult = ["t" => $taxonomies["Pair"], "h" => $h]; } else { $handResult = ["t" => $taxonomies["High Card"], "h" => $h]; } return $handResult; } function DetermineWinnerByTie($hand1, $hand2) { // hand score is equal to sum of value plus taxonomy $s1 = $s2 = 0; foreach($hand1 as $x) { $s1 += $x['value']; } foreach($hand2 as $x) { $s2 += $x['value']; } return $s1 <=> $s2; } function DetermineWinner($hand1, $hand2) { // hand score is equal to sum of sort order plus taxonomy if (reset($hand1['t']) == reset($hand2['t'])) { $result = DetermineWinnerByTie($hand1['h'], $hand2['h']); } else { $result = reset($hand1['t']) <=> reset($hand2['t']); } return $result; } $cards = [ "AS" => ["sort" => 14, "suite" => "S", "value" => 11], "AC" => ["sort" => 14, "suite" => "C", "value" => 11], "AD" => ["sort" => 14, "suite" => "D", "value" => 11], "AH" => ["sort" => 14, "suite" => "H", "value" => 11], "KS" => ["sort" => 13, "suite" => "S", "value" => 10], "KC" => ["sort" => 13, "suite" => "C", "value" => 10], "KD" => ["sort" => 13, "suite" => "D", "value" => 10], "KH" => ["sort" => 13, "suite" => "H", "value" => 10], "QS" => ["sort" => 12, "suite" => "S", "value" => 10], "QC" => ["sort" => 12, "suite" => "C", "value" => 10], "QD" => ["sort" => 12, "suite" => "D", "value" => 10], "QH" => ["sort" => 12, "suite" => "H", "value" => 10], "JS" => ["sort" => 11, "suite" => "S", "value" => 10], "JC" => ["sort" => 11, "suite" => "C", "value" => 10], "JD" => ["sort" => 11, "suite" => "D", "value" => 10], "JH" => ["sort" => 11, "suite" => "H", "value" => 10], "10S" => ["sort" => 10, "suite" => "S", "value" => 10], "10C" => ["sort" => 10, "suite" => "C", "value" => 10], "10D" => ["sort" => 10, "suite" => "D", "value" => 10], "10H" => ["sort" => 10, "suite" => "H", "value" => 10], "9S" => ["sort" => 9, "suite" => "S", "value" => 9], "9C" => ["sort" => 9, "suite" => "C", "value" => 9], "9D" => ["sort" => 9, "suite" => "D", "value" => 9], "9H" => ["sort" => 9, "suite" => "H", "value" => 9], "8S" => ["sort" => 8, "suite" => "S", "value" => 8], "8C" => ["sort" => 8, "suite" => "C", "value" => 8], "8D" => ["sort" => 8, "suite" => "D", "value" => 8], "8H" => ["sort" => 8, "suite" => "H", "value" => 8], "7S" => ["sort" => 7, "suite" => "S", "value" => 7], "7C" => ["sort" => 7, "suite" => "C", "value" => 7], "7D" => ["sort" => 7, "suite" => "D", "value" => 7], "7H" => ["sort" => 7, "suite" => "H", "value" => 7], "6S" => ["sort" => 6, "suite" => "S", "value" => 6], "6C" => ["sort" => 6, "suite" => "C", "value" => 6], "6D" => ["sort" => 6, "suite" => "D", "value" => 6], "6H" => ["sort" => 6, "suite" => "H", "value" => 6], "5S" => ["sort" => 5, "suite" => "S", "value" => 5], "5C" => ["sort" => 5, "suite" => "C", "value" => 5], "5D" => ["sort" => 5, "suite" => "D", "value" => 5], "5H" => ["sort" => 5, "suite" => "H", "value" => 5], "4S" => ["sort" => 4, "suite" => "S", "value" => 4], "4C" => ["sort" => 4, "suite" => "C", "value" => 4], "4D" => ["sort" => 4, "suite" => "D", "value" => 4], "4H" => ["sort" => 4, "suite" => "H", "value" => 4], "3S" => ["sort" => 3, "suite" => "S", "value" => 3], "3C" => ["sort" => 3, "suite" => "C", "value" => 3], "3D" => ["sort" => 3, "suite" => "D", "value" => 3], "3H" => ["sort" => 3, "suite" => "H", "value" => 3], "2S" => ["sort" => 2, "suite" => "S", "value" => 2], "2C" => ["sort" => 2, "suite" => "C", "value" => 2], "2D" => ["sort" => 2, "suite" => "D", "value" => 2], "2H" => ["sort" => 2, "suite" => "H", "value" => 2], ]; $board = $player1 = $player2 = []; shuffleCards($cards); [$cards, $player1] = dealCards($cards, 2); [$cards, $player2] = dealCards($cards, 2); [$cards, $board] = dealCards($cards, 5); $board1 = combineHands($board, $player1); $board2 = combineHands($board, $player2); $board1 = sortCardsBySortOrder($board1); $b1 = array_slice($board1, 0, 5); $board2 = sortCardsBySortOrder($board2); $b2 = array_slice($board2, 0, 5); echo "Board: ", getCardsAsString($board), "\n"; echo "Player 1: ", getCardsAsString($player1), "\n"; echo "Player 2: ", getCardsAsString($player2), "\n\n"; $hand1 = DetermineHand($player1, $board); $hand2 = DetermineHand($player2, $board); echo "Player 1 has: ", key($hand1['t']), " - ", getCardsAsString($hand1['h']), "\n"; echo "Player 2 has: ", key($hand2['t']), " - ", getCardsAsString($hand2['h']), "\n"; if (($win = DetermineWinner($hand1, $hand2)) == -1) { echo "Player 2 wins!\n"; } elseif ($win == 1) { echo "Player 1 wins!\n"; } else { echo "It's a tie!\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 125, Position 2 = 127
Branch analysis from position: 125
1 jumps found. (Code = 42) Position 1 = 132
Branch analysis from position: 132
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 127
2 jumps found. (Code = 43) Position 1 = 129, Position 2 = 131
Branch analysis from position: 129
1 jumps found. (Code = 42) Position 1 = 132
Branch analysis from position: 132
Branch analysis from position: 131
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WhiSn
function name:  (null)
number of ops:  133
compiled vars:  !0 = $cards, !1 = $board, !2 = $player1, !3 = $player2, !4 = $board1, !5 = $board2, !6 = $b1, !7 = $b2, !8 = $hand1, !9 = $hand2, !10 = $win
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  421     0  E >   ASSIGN                                                   !0, <array>
  488     1        ASSIGN                                           ~12     !3, <array>
          2        ASSIGN                                           ~13     !2, ~12
          3        ASSIGN                                                   !1, ~13
  490     4        INIT_FCALL                                               'shufflecards'
          5        SEND_VAR                                                 !0
          6        DO_FCALL                                      0          
  491     7        INIT_FCALL                                               'dealcards'
          8        SEND_VAR                                                 !0
          9        SEND_VAL                                                 2
         10        DO_FCALL                                      0  $16     
         11        FETCH_LIST_R                                     $17     $16, 0
         12        ASSIGN                                                   !0, $17
         13        FETCH_LIST_R                                     $19     $16, 1
         14        ASSIGN                                                   !2, $19
         15        FREE                                                     $16
  492    16        INIT_FCALL                                               'dealcards'
         17        SEND_VAR                                                 !0
         18        SEND_VAL                                                 2
         19        DO_FCALL                                      0  $21     
         20        FETCH_LIST_R                                     $22     $21, 0
         21        ASSIGN                                                   !0, $22
         22        FETCH_LIST_R                                     $24     $21, 1
         23        ASSIGN                                                   !3, $24
         24        FREE                                                     $21
  494    25        INIT_FCALL                                               'dealcards'
         26        SEND_VAR                                                 !0
         27        SEND_VAL                                                 5
         28        DO_FCALL                                      0  $26     
         29        FETCH_LIST_R                                     $27     $26, 0
         30        ASSIGN                                                   !0, $27
         31        FETCH_LIST_R                                     $29     $26, 1
         32        ASSIGN                                                   !1, $29
         33        FREE                                                     $26
  496    34        INIT_FCALL                                               'combinehands'
         35        SEND_VAR                                                 !1
         36        SEND_VAR                                                 !2
         37        DO_FCALL                                      0  $31     
         38        ASSIGN                                                   !4, $31
  497    39        INIT_FCALL                                               'combinehands'
         40        SEND_VAR                                                 !1
         41        SEND_VAR                                                 !3
         42        DO_FCALL                                      0  $33     
         43        ASSIGN                                                   !5, $33
  499    44        INIT_FCALL                                               'sortcardsbysortorder'
         45        SEND_VAR                                                 !4
         46        DO_FCALL                                      0  $35     
         47        ASSIGN                                                   !4, $35
  500    48        INIT_FCALL                                               'array_slice'
         49        SEND_VAR                                                 !4
         50        SEND_VAL                                                 0
         51        SEND_VAL                                                 5
         52        DO_ICALL                                         $37     
         53        ASSIGN                                                   !6, $37
  501    54        INIT_FCALL                                               'sortcardsbysortorder'
         55        SEND_VAR                                                 !5
         56        DO_FCALL                                      0  $39     
         57        ASSIGN                                                   !5, $39
  502    58        INIT_FCALL                                               'array_slice'
         59        SEND_VAR                                                 !5
         60        SEND_VAL                                                 0
         61        SEND_VAL                                                 5
         62        DO_ICALL                                         $41     
         63        ASSIGN                                                   !7, $41
  504    64        ECHO                                                     'Board%3A+'
         65        INIT_FCALL                                               'getcardsasstring'
         66        SEND_VAR                                                 !1
         67        DO_FCALL                                      0  $43     
         68        ECHO                                                     $43
         69        ECHO                                                     '%0A'
  505    70        ECHO                                                     'Player+1%3A+'
         71        INIT_FCALL                                               'getcardsasstring'
         72        SEND_VAR                                                 !2
         73        DO_FCALL                                      0  $44     
         74        ECHO                                                     $44
         75        ECHO                                                     '%0A'
  506    76        ECHO                                                     'Player+2%3A+'
         77        INIT_FCALL                                               'getcardsasstring'
         78        SEND_VAR                                                 !3
         79        DO_FCALL                                      0  $45     
         80        ECHO                                                     $45
         81        ECHO                                                     '%0A%0A'
  509    82        INIT_FCALL                                               'determinehand'
         83        SEND_VAR                                                 !2
         84        SEND_VAR                                                 !1
         85        DO_FCALL                                      0  $46     
         86        ASSIGN                                                   !8, $46
  510    87        INIT_FCALL                                               'determinehand'
         88        SEND_VAR                                                 !3
         89        SEND_VAR                                                 !1
         90        DO_FCALL                                      0  $48     
         91        ASSIGN                                                   !9, $48
  512    92        ECHO                                                     'Player+1+has%3A+'
         93        INIT_FCALL                                               'key'
         94        FETCH_DIM_R                                      ~50     !8, 't'
         95        SEND_VAL                                                 ~50
         96        DO_ICALL                                         $51     
         97        ECHO                                                     $51
         98        ECHO                                                     '+-+'
         99        INIT_FCALL                                               'getcardsasstring'
        100        FETCH_DIM_R                                      ~52     !8, 'h'
        101        SEND_VAL                                                 ~52
        102        DO_FCALL                                      0  $53     
        103        ECHO                                                     $53
        104        ECHO                                                     '%0A'
  513   105        ECHO                                                     'Player+2+has%3A+'
        106        INIT_FCALL                                               'key'
        107        FETCH_DIM_R                                      ~54     !9, 't'
        108        SEND_VAL                                                 ~54
        109        DO_ICALL                                         $55     
        110        ECHO                                                     $55
        111        ECHO                                                     '+-+'
        112        INIT_FCALL                                               'getcardsasstring'
        113        FETCH_DIM_R                                      ~56     !9, 'h'
        114        SEND_VAL                                                 ~56
        115        DO_FCALL                                      0  $57     
        116        ECHO                                                     $57
        117        ECHO                                                     '%0A'
  515   118        INIT_FCALL                                               'determinewinner'
        119        SEND_VAR                                                 !8
        120        SEND_VAR                                                 !9
        121        DO_FCALL                                      0  $58     
        122        ASSIGN                                           ~59     !10, $58
        123        IS_EQUAL                                                 ~59, -1
        124      > JMPZ                                                     ~60, ->127
  516   125    >   ECHO                                                     'Player+2+wins%21%0A'
        126      > JMP                                                      ->132
  517   127    >   IS_EQUAL                                                 !10, 1
        128      > JMPZ                                                     ~61, ->131
  518   129    >   ECHO                                                     'Player+1+wins%21%0A'
        130      > JMP                                                      ->132
  520   131    >   ECHO                                                     'It%27s+a+tie%21%0A'
  521   132    > > RETURN                                                   1

Function sortcardsbysortorder:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 32
Branch analysis from position: 15
2 jumps found. (Code = 77) Position 1 = 25, Position 2 = 30
Branch analysis from position: 25
2 jumps found. (Code = 78) Position 1 = 26, Position 2 = 30
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
Branch analysis from position: 32
Branch analysis from position: 9
filename:       /in/WhiSn
function name:  sortCardsBySortOrder
number of ops:  36
compiled vars:  !0 = $cards, !1 = $reverse, !2 = $changeAce, !3 = $ace, !4 = $tmpArr, !5 = $details, !6 = $card
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <false>
    4     2        ASSIGN                                                   !2, <false>
    5     3        INIT_FCALL_BY_NAME                                       'isLowStraight'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0  $8      
          6      > JMPZ                                                     $8, ->9
    6     7    >   ASSIGN                                                   !1, <true>
    7     8        ASSIGN                                                   !2, <true>
   10     9    >   INIT_FCALL_BY_NAME                                       'sortCards'
         10        SEND_VAR_EX                                              !0
         11        SEND_VAR_EX                                              !1
         12        DO_FCALL                                      0  $11     
         13        ASSIGN                                                   !0, $11
   12    14      > JMPZ                                                     !2, ->32
   13    15    >   INIT_FCALL                                               'array_pop'
         16        SEND_REF                                                 !0
         17        DO_ICALL                                         $13     
         18        ASSIGN                                                   !3, $13
   15    19        ASSIGN                                                   !4, <array>
   16    20        FETCH_DIM_R                                      ~16     !3, 'suite'
         21        CONCAT                                           ~17     'A', ~16
         22        ASSIGN_DIM                                               !4, ~17
         23        OP_DATA                                                  !3
   17    24      > FE_RESET_R                                       $19     !0, ->30
         25    > > FE_FETCH_R                                       ~20     $19, !5, ->30
         26    >   ASSIGN                                                   !6, ~20
   18    27        ASSIGN_DIM                                               !4, !6
         28        OP_DATA                                                  !5
   17    29      > JMP                                                      ->25
         30    >   FE_FREE                                                  $19
   21    31        ASSIGN                                                   !0, !4
   24    32    >   VERIFY_RETURN_TYPE                                       !0
         33      > RETURN                                                   !0
   25    34*       VERIFY_RETURN_TYPE                                       
         35*     > RETURN                                                   null

End of function sortcardsbysortorder

Function sortcards:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WhiSn
function name:  sortCards
number of ops:  12
compiled vars:  !0 = $cards, !1 = $reverse
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <false>
   28     2        INIT_FCALL                                               'uasort'
          3        SEND_REF                                                 !0
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FWhiSn%3A28%240'
          5        BIND_LEXICAL                                             ~2, !1
   38     6        SEND_VAL                                                 ~2
          7        DO_ICALL                                                 
   40     8        VERIFY_RETURN_TYPE                                       !0
          9      > RETURN                                                   !0
   41    10*       VERIFY_RETURN_TYPE                                       
         11*     > RETURN                                                   null

End of function sortcards

Function %00%7Bclosure%7D%2Fin%2FWhiSn%3A28%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 10
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 16
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
Branch analysis from position: 10
filename:       /in/WhiSn
function name:  {closure}
number of ops:  18
compiled vars:  !0 = $a, !1 = $b, !2 = $reverse, !3 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   29     3        FETCH_DIM_R                                      ~4      !0, 'sort'
          4        FETCH_DIM_R                                      ~5      !1, 'sort'
          5        SPACESHIP                                        ~6      ~4, ~5
          6        ASSIGN                                                   !3, ~6
   30     7        BOOL_NOT                                         ~8      !2
          8      > JMPZ                                                     ~8, ->10
   31     9    >   ASSIGN_OP                                     3          !3, -1
   33    10    >   IS_EQUAL                                                 !3, 0
         11      > JMPZ                                                     ~10, ->16
   34    12    >   FETCH_DIM_R                                      ~11     !0, 'suite'
         13        FETCH_DIM_R                                      ~12     !1, 'suite'
         14        SPACESHIP                                        ~13     ~11, ~12
         15        ASSIGN                                                   !3, ~13
   37    16    > > RETURN                                                   !3
   38    17*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FWhiSn%3A28%240

Function sortcardsbysuite:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WhiSn
function name:  sortCardsBySuite
number of ops:  12
compiled vars:  !0 = $cards, !1 = $reverse
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <false>
   44     2        INIT_FCALL                                               'uasort'
          3        SEND_REF                                                 !0
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FWhiSn%3A44%241'
          5        BIND_LEXICAL                                             ~2, !1
   54     6        SEND_VAL                                                 ~2
          7        DO_ICALL                                                 
   55     8        VERIFY_RETURN_TYPE                                       !0
          9      > RETURN                                                   !0
   56    10*       VERIFY_RETURN_TYPE                                       
         11*     > RETURN                                                   null

End of function sortcardsbysuite

Function %00%7Bclosure%7D%2Fin%2FWhiSn%3A44%241:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 13
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 16
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
Branch analysis from position: 13
filename:       /in/WhiSn
function name:  {closure}
number of ops:  18
compiled vars:  !0 = $a, !1 = $b, !2 = $reverse, !3 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   45     3        FETCH_DIM_R                                      ~4      !0, 'suite'
          4        FETCH_DIM_R                                      ~5      !1, 'suite'
          5        SPACESHIP                                        ~6      ~4, ~5
          6        ASSIGN                                                   !3, ~6
   46     7        IS_EQUAL                                                 !3, 0
          8      > JMPZ                                                     ~8, ->13
   47     9    >   FETCH_DIM_R                                      ~9      !0, 'sort'
         10        FETCH_DIM_R                                      ~10     !1, 'sort'
         11        SPACESHIP                                        ~11     ~9, ~10
         12        ASSIGN                                                   !3, ~11
   49    13    >   BOOL_NOT                                         ~13     !2
         14      > JMPZ                                                     ~13, ->16
   50    15    >   ASSIGN_OP                                     3          !3, -1
   53    16    > > RETURN                                                   !3
   54    17*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FWhiSn%3A44%241

Function shufflecards:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 3
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 3
Branch analysis from position: 12
Branch analysis from position: 3
filename:       /in/WhiSn
function name:  shuffleCards
number of ops:  16
compiled vars:  !0 = $cards, !1 = $shuffled, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   58     0  E >   RECV                                             !0      
   59     1        ASSIGN                                                   !1, <array>
   60     2      > JMP                                                      ->11
   61     3    >   INIT_FCALL                                               'array_rand'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $4      
          6        ASSIGN                                                   !2, $4
   62     7        FETCH_DIM_R                                      ~7      !0, !2
          8        ASSIGN_DIM                                               !1, !2
          9        OP_DATA                                                  ~7
   63    10        UNSET_DIM                                                !0, !2
   60    11    > > JMPNZ                                                    !0, ->3
   66    12    >   VERIFY_RETURN_TYPE                                       !1
         13      > RETURN                                                   !1
   67    14*       VERIFY_RETURN_TYPE                                       
         15*     > RETURN                                                   null

End of function shufflecards

Function dealcards:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 5
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 5
Branch analysis from position: 17
Branch analysis from position: 5
filename:       /in/WhiSn
function name:  dealCards
number of ops:  21
compiled vars:  !0 = $cards, !1 = $num, !2 = $result, !3 = $i, !4 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   69     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      1
   70     2        ASSIGN                                                   !2, <array>
   71     3        ASSIGN                                                   !3, 0
          4      > JMP                                                      ->15
   72     5    >   INIT_FCALL                                               'array_rand'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $7      
          8        ASSIGN                                                   !4, $7
   73     9        FETCH_DIM_R                                      ~11     !0, !4
         10        FETCH_DIM_W                                      $9      !2, 1
         11        ASSIGN_DIM                                               $9, !4
         12        OP_DATA                                                  ~11
   74    13        UNSET_DIM                                                !0, !4
   71    14        PRE_INC                                                  !3
         15    >   IS_SMALLER                                               !3, !1
         16      > JMPNZ                                                    ~13, ->5
   76    17    >   ASSIGN_DIM                                               !2, 0
         18        OP_DATA                                                  !0
   78    19      > RETURN                                                   !2
   80    20*     > RETURN                                                   null

End of function dealcards

Function getlargestsuite:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 17
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 17
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 12
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 12
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/WhiSn
function name:  getLargestSuite
number of ops:  30
compiled vars:  !0 = $cards, !1 = $result, !2 = $lastSuite, !3 = $streak, !4 = $details, !5 = $card, !6 = $suite
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   82     0  E >   RECV                                             !0      
   83     1        ASSIGN                                                   !1, <array>
   85     2        ASSIGN                                                   !2, ''
   86     3        ASSIGN                                                   !3, <array>
   87     4      > FE_RESET_R                                       $10     !0, ->17
          5    > > FE_FETCH_R                                       ~11     $10, !4, ->17
          6    >   ASSIGN                                                   !5, ~11
   88     7        FETCH_DIM_R                                      ~13     !4, 'suite'
          8        ASSIGN                                                   !6, ~13
   89     9        IS_NOT_EQUAL                                             !6, !2
         10      > JMPZ                                                     ~15, ->12
   90    11    >   ASSIGN                                                   !2, !6
   92    12    >   INIT_ARRAY                                       ~19     !4, !5
         13        FETCH_DIM_W                                      $17     !3, !6
         14        ASSIGN_DIM                                               $17, !5
         15        OP_DATA                                                  ~19
   87    16      > JMP                                                      ->5
         17    >   FE_FREE                                                  $10
   95    18        INIT_FCALL                                               'uasort'
         19        SEND_REF                                                 !3
         20        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FWhiSn%3A95%242'
  105    21        SEND_VAL                                                 ~20
         22        DO_ICALL                                                 
  107    23        INIT_FCALL                                               'array_pop'
         24        SEND_REF                                                 !3
         25        DO_ICALL                                         $22     
         26        VERIFY_RETURN_TYPE                                       $22
         27      > RETURN                                                   $22
  108    28*       VERIFY_RETURN_TYPE                                       
         29*     > RETURN                                                   null

End of function getlargestsuite

Function %00%7Bclosure%7D%2Fin%2FWhiSn%3A95%242:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 28
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/WhiSn
function name:  {closure}
number of ops:  30
compiled vars:  !0 = $a, !1 = $b, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   95     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   96     2        COUNT                                            ~3      !0
          3        COUNT                                            ~4      !1
          4        SPACESHIP                                        ~5      ~3, ~4
          5        ASSIGN                                                   !2, ~5
   98     6        IS_EQUAL                                                 !2, 0
          7      > JMPZ                                                     ~7, ->28
   99     8    >   INIT_FCALL                                               'arr

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.51 ms | 1435 KiB | 39 Q