3v4l.org

run code in 300+ PHP versions simultaneously
<?php function isSolvable($choices1, $choices2, $capacities, $n) { if($n==0) return true; // No students left to allocate // First choice $c1 = $choices1[$n-1]; if($capacities[$c1]>0) { $capacities[$c1]--; if(isSolvable($choices1, $choices2, $capacities, $n-1)) return true; $capacities[$c1]++; } // Second choice $c2 = $choices2[$n-1]; if($c2>=0 && $capacities[$c2]>0) { $capacities[$c2]--; if(isSolvable($choices1, $choices2, $capacities, $n-1)) return true; } return false; } $choices1 = [0, 0, 1, 2]; $choices2 = [-1, 2, -1, -1]; $capacities = [2, 1, 1]; echo isSolvable($choices1, $choices2, $capacities, count($choices1)) ? 'YES' : 'NO'; ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JMECG
function name:  (null)
number of ops:  16
compiled vars:  !0 = $choices1, !1 = $choices2, !2 = $capacities
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   ASSIGN                                                   !0, <array>
   30     1        ASSIGN                                                   !1, <array>
   31     2        ASSIGN                                                   !2, <array>
   32     3        INIT_FCALL                                               'issolvable'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        SEND_VAR                                                 !2
          7        COUNT                                            ~6      !0
          8        SEND_VAL                                                 ~6
          9        DO_FCALL                                      0  $7      
         10      > JMPZ                                                     $7, ->13
         11    >   QM_ASSIGN                                        ~8      'YES'
         12      > JMP                                                      ->14
         13    >   QM_ASSIGN                                        ~8      'NO'
         14    >   ECHO                                                     ~8
   33    15      > RETURN                                                   1

Function issolvable:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 26
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 24
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
2 jumps found. (Code = 46) Position 1 = 31, Position 2 = 34
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 46
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 45, Position 2 = 46
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 46
Branch analysis from position: 34
Branch analysis from position: 26
filename:       /in/JMECG
function name:  isSolvable
number of ops:  48
compiled vars:  !0 = $choices1, !1 = $choices2, !2 = $capacities, !3 = $n, !4 = $c1, !5 = $c2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
    4     4        IS_EQUAL                                                 !3, 0
          5      > JMPZ                                                     ~6, ->7
    5     6    > > RETURN                                                   <true>
    8     7    >   SUB                                              ~7      !3, 1
          8        FETCH_DIM_R                                      ~8      !0, ~7
          9        ASSIGN                                                   !4, ~8
    9    10        FETCH_DIM_R                                      ~10     !2, !4
         11        IS_SMALLER                                               0, ~10
         12      > JMPZ                                                     ~11, ->26
   11    13    >   FETCH_DIM_RW                                     $12     !2, !4
         14        PRE_DEC                                                  $12
   12    15        INIT_FCALL_BY_NAME                                       'isSolvable'
         16        SEND_VAR_EX                                              !0
         17        SEND_VAR_EX                                              !1
         18        SEND_VAR_EX                                              !2
         19        SUB                                              ~14     !3, 1
         20        SEND_VAL_EX                                              ~14
         21        DO_FCALL                                      0  $15     
         22      > JMPZ                                                     $15, ->24
   13    23    > > RETURN                                                   <true>
   14    24    >   FETCH_DIM_RW                                     $16     !2, !4
         25        PRE_INC                                                  $16
   18    26    >   SUB                                              ~18     !3, 1
         27        FETCH_DIM_R                                      ~19     !1, ~18
         28        ASSIGN                                                   !5, ~19
   19    29        IS_SMALLER_OR_EQUAL                              ~21     0, !5
         30      > JMPZ_EX                                          ~21     ~21, ->34
         31    >   FETCH_DIM_R                                      ~22     !2, !5
         32        IS_SMALLER                                       ~23     0, ~22
         33        BOOL                                             ~21     ~23
         34    > > JMPZ                                                     ~21, ->46
   21    35    >   FETCH_DIM_RW                                     $24     !2, !5
         36        PRE_DEC                                                  $24
   22    37        INIT_FCALL_BY_NAME                                       'isSolvable'
         38        SEND_VAR_EX                                              !0
         39        SEND_VAR_EX                                              !1
         40        SEND_VAR_EX                                              !2
         41        SUB                                              ~26     !3, 1
         42        SEND_VAL_EX                                              ~26
         43        DO_FCALL                                      0  $27     
         44      > JMPZ                                                     $27, ->46
   23    45    > > RETURN                                                   <true>
   26    46    > > RETURN                                                   <false>
   27    47*     > RETURN                                                   null

End of function issolvable

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
227.72 ms | 1011 KiB | 14 Q