Last active
April 7, 2016 19:32
-
-
Save allyburns/7e278092c5a738785715f8939266946f to your computer and use it in GitHub Desktop.
My entry to the Blonde Code Golf Challenge April 2016
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function checkout($number) { | |
$s=$f=[50=>bull];foreach(range(1,20)as$d){$s[$d*3]=t.$d;$f[$p=$d*2]=$s[$p]=d.$d;$s[$d]=$d;}$o=$f;foreach($f as$v=>$l)foreach($s as$b=>$a){$f[$h=$v+$b]||$o[$h]="$a, $l";foreach($s as$d=>$c)$o[$q=$v+$b+$d]=$o[$q]??"$c, $a, $l";}return$o[$number]; | |
} | |
// and expaned a bit for readability | |
$s =$f = [50 => bull]; | |
foreach (range(1,20) as $d) { | |
$s[$d*3] = t.$d; | |
$f[$p=$d*2] = $s[$p] = d.$d; | |
$s[$d] = $d; | |
} | |
$o=$f; // outs start off as the one dart finishers | |
foreach ($f as $v => $l) | |
foreach ($s as $b => $a) { // create 2 dart finishes | |
$f[$h=$v+$b] || $o[$h]="$a, $l"; // don't make if there is a 1 dart finish | |
foreach($s as $d => $c) $o[$q=$v+$b+$d] = $o[$q] ?? "$c, $a, $l"; // create 3 dart finishes, if there is not a better finish | |
} | |
return$o[$number]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment