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'; ?>
Output for git.master, git.master_jit, rfc.property-hooks
YES

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
90.94 ms | 405 KiB | 5 Q