3v4l.org

run code in 300+ PHP versions simultaneously
<?php $challenges = [ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, ]; $permutations = []; $scores = []; for ($i = 0; $i < 100000; $i++) { shuffle($challenges); $key = implode('', $challenges); $permutations[$key] = isset($permutations[$key]) ? $permutations[$key] + 1 : 1; $score = 0; foreach ($challenges as $challenge) { $score += $challenge; $scores[$score] = isset($scores[$score]) ? $scores[$score] + 1 : 1; } } ksort($scores); echo "\nUnique permutations generated: " . count($permutations); echo "\nUnique scores found: " . count($scores) . "\n\n"; echo "Score\tCount\n"; foreach ($scores as $score => $count) { echo "{$score}\t$count\n"; } echo "\n"; foreach ($permutations as $key => $count) { if ($count > 1) { echo "\nPermutation occurred {$count} times: " . $key; } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 5
Branch analysis from position: 40
2 jumps found. (Code = 77) Position 1 = 52, Position 2 = 60
Branch analysis from position: 52
2 jumps found. (Code = 78) Position 1 = 53, Position 2 = 60
Branch analysis from position: 53
1 jumps found. (Code = 42) Position 1 = 52
Branch analysis from position: 52
Branch analysis from position: 60
2 jumps found. (Code = 77) Position 1 = 63, Position 2 = 73
Branch analysis from position: 63
2 jumps found. (Code = 78) Position 1 = 64, Position 2 = 73
Branch analysis from position: 64
2 jumps found. (Code = 43) Position 1 = 67, Position 2 = 72
Branch analysis from position: 67
1 jumps found. (Code = 42) Position 1 = 63
Branch analysis from position: 63
Branch analysis from position: 72
Branch analysis from position: 73
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 73
Branch analysis from position: 60
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 19
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
2 jumps found. (Code = 77) Position 1 = 24, Position 2 = 36
Branch analysis from position: 24
2 jumps found. (Code = 78) Position 1 = 25, Position 2 = 36
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 32
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 5
Branch analysis from position: 40
Branch analysis from position: 5
Branch analysis from position: 36
Branch analysis from position: 19
2 jumps found. (Code = 77) Position 1 = 24, Position 2 = 36
Branch analysis from position: 24
Branch analysis from position: 36
filename:       /in/s2FVR
function name:  (null)
number of ops:  75
compiled vars:  !0 = $challenges, !1 = $permutations, !2 = $scores, !3 = $i, !4 = $key, !5 = $score, !6 = $challenge, !7 = $count
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   10     1        ASSIGN                                                   !1, <array>
   11     2        ASSIGN                                                   !2, <array>
   13     3        ASSIGN                                                   !3, 0
          4      > JMP                                                      ->38
   14     5    >   INIT_FCALL                                               'shuffle'
          6        SEND_REF                                                 !0
          7        DO_ICALL                                                 
   15     8        INIT_FCALL                                               'implode'
          9        SEND_VAL                                                 ''
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $13     
         12        ASSIGN                                                   !4, $13
   16    13        ISSET_ISEMPTY_DIM_OBJ                         0          !1, !4
         14      > JMPZ                                                     ~16, ->19
         15    >   FETCH_DIM_R                                      ~17     !1, !4
         16        ADD                                              ~18     ~17, 1
         17        QM_ASSIGN                                        ~19     ~18
         18      > JMP                                                      ->20
         19    >   QM_ASSIGN                                        ~19     1
         20    >   ASSIGN_DIM                                               !1, !4
         21        OP_DATA                                                  ~19
   17    22        ASSIGN                                                   !5, 0
   18    23      > FE_RESET_R                                       $21     !0, ->36
         24    > > FE_FETCH_R                                               $21, !6, ->36
   19    25    >   ASSIGN_OP                                     1          !5, !6
   20    26        ISSET_ISEMPTY_DIM_OBJ                         0          !2, !5
         27      > JMPZ                                                     ~24, ->32
         28    >   FETCH_DIM_R                                      ~25     !2, !5
         29        ADD                                              ~26     ~25, 1
         30        QM_ASSIGN                                        ~27     ~26
         31      > JMP                                                      ->33
         32    >   QM_ASSIGN                                        ~27     1
         33    >   ASSIGN_DIM                                               !2, !5
         34        OP_DATA                                                  ~27
   18    35      > JMP                                                      ->24
         36    >   FE_FREE                                                  $21
   13    37        PRE_INC                                                  !3
         38    >   IS_SMALLER                                               !3, 100000
         39      > JMPNZ                                                    ~29, ->5
   24    40    >   INIT_FCALL                                               'ksort'
         41        SEND_REF                                                 !2
         42        DO_ICALL                                                 
   26    43        COUNT                                            ~31     !1
         44        CONCAT                                           ~32     '%0AUnique+permutations+generated%3A+', ~31
         45        ECHO                                                     ~32
   27    46        COUNT                                            ~33     !2
         47        CONCAT                                           ~34     '%0AUnique+scores+found%3A+', ~33
         48        CONCAT                                           ~35     ~34, '%0A%0A'
         49        ECHO                                                     ~35
   28    50        ECHO                                                     'Score%09Count%0A'
   29    51      > FE_RESET_R                                       $36     !2, ->60
         52    > > FE_FETCH_R                                       ~37     $36, !7, ->60
         53    >   ASSIGN                                                   !5, ~37
   30    54        ROPE_INIT                                     4  ~40     !5
         55        ROPE_ADD                                      1  ~40     ~40, '%09'
         56        ROPE_ADD                                      2  ~40     ~40, !7
         57        ROPE_END                                      3  ~39     ~40, '%0A'
         58        ECHO                                                     ~39
   29    59      > JMP                                                      ->52
         60    >   FE_FREE                                                  $36
   32    61        ECHO                                                     '%0A'
   34    62      > FE_RESET_R                                       $42     !1, ->73
         63    > > FE_FETCH_R                                       ~43     $42, !7, ->73
         64    >   ASSIGN                                                   !4, ~43
   35    65        IS_SMALLER                                               1, !7
         66      > JMPZ                                                     ~45, ->72
   36    67    >   ROPE_INIT                                     3  ~47     '%0APermutation+occurred+'
         68        ROPE_ADD                                      1  ~47     ~47, !7
         69        ROPE_END                                      2  ~46     ~47, '+times%3A+'
         70        CONCAT                                           ~49     ~46, !4
         71        ECHO                                                     ~49
   34    72    > > JMP                                                      ->63
         73    >   FE_FREE                                                  $42
   38    74      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.79 ms | 1016 KiB | 16 Q