diff options
| author | drbaggy <js5@sanger.ac.uk> | 2021-08-05 09:19:48 +0100 |
|---|---|---|
| committer | drbaggy <js5@sanger.ac.uk> | 2021-08-05 09:19:48 +0100 |
| commit | 9d1845a3fc2d4ff8d120d2095b552a2b250ba499 (patch) | |
| tree | a87aa908359ea24a75abd60a1384867bf3de9d67 | |
| parent | 01d189f6488f5f14c8f54986bec0f0ce0158bba5 (diff) | |
| download | perlweeklychallenge-club-9d1845a3fc2d4ff8d120d2095b552a2b250ba499.tar.gz perlweeklychallenge-club-9d1845a3fc2d4ff8d120d2095b552a2b250ba499.tar.bz2 perlweeklychallenge-club-9d1845a3fc2d4ff8d120d2095b552a2b250ba499.zip | |
tidied up
| -rw-r--r-- | challenge-124/james-smith/php/ch-2.php | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/challenge-124/james-smith/php/ch-2.php b/challenge-124/james-smith/php/ch-2.php index 0696562330..2a888e40ee 100644 --- a/challenge-124/james-smith/php/ch-2.php +++ b/challenge-124/james-smith/php/ch-2.php @@ -12,11 +12,8 @@ function match_teams( $teams ) { implode( ' ', $bt[1] ), implode( ' ', $bt[2] ), $bt[0] ); } -function separate( $m, $t1, $t2, $d, &$b, $w ) { - if(!sizeof($w)) { - if( $b[0]>abs($d) ) list($b[0],$b[1],$b[2]) = [abs($d),$t1,$t2]; - return; - } +function separate( $m, $t1, $t2, $d, &$b, $w ) { // & in front of $b as pass by reference! + if(!sizeof($w)) return ( $b[0]>abs($d) ) && ( $b = [abs($d),$t1,$t2] ); $n = array_shift( $w ); if( sizeof($t1)<$m ) separate( $m, array_merge($t1,[$n]), $t2, $d+$n, $b, $w ); if( sizeof($t2)<$m ) separate( $m, $t1, array_merge($t2,[$n]), $d-$n, $b, $w ); |
