Code Golf Golf Score
PHP 5.3+, 173 167 166 159 156 151 127 121 bytes
echo[Condor,Albatross,Eagle,Birdie,Par,$b=Bogey,"Double $b","Triple $b","Haha you loser"][min(4+$s-$p,8)]?:"Hole in one";
Notice-free version, echo$s-1?["Condor","Albatross","Eagle","Birdie","Par",$b="Bogey","Double $b","Triple $b","Haha you loser"][min(4+$s-$p,8)]:"Hole in one";
Set $s
core and $p
ar variables before the echo
and you're off.
echo [Condor,
Albatross,
Eagle,
Birdie,
Par,
$b = Bogey,
"Double $b",
"Triple $b",
"Haha you loser"][ min( 4+$s-$p,8 ) ]
?: "Hole in one";
Edits
-6: Not storing the array, just calling it if need be.
-1: Flipping the ternary around.
-7: The lowest $s-$p
with $s>1
is -4
, so the max()
isn't necessary, since 4+$s-$p >= 0
.
-3: Array -> explode()
, thanks CoolestVeto!
-5: Cheaty string literal undefined constant plus $r[-1] -> false
, thanks Ismael Miguel!
-24: Moving from an explode()
function to a printf
/%s
setup, with some tweaks, more thanks to Ismael Miguel for the change of direction.
-6: Swerve, we're back to echo
again!
05AB1E, 91 90 bytes
Code:
-5+U“¥Ê€†€µ“ª"0Bogey"ДCondor Albatross²è Birdie Par ÿ‹¶ÿ½¿ÿ”ð¡“Haha€î loser“X0¹1Qm*@0ð:ðÛ
Explanation:
Part 1:
-5+ # Computes Score - Par + 5
U # Store in X
“¥Ê€†€µ“ª # Short for "Hole in one"
"0Bogey" # Push this string
Ð # Triplicate
Part 2:
”Condor Albatross²è Birdie Par ÿ‹¶ÿ½¿ÿ”ð¡
This is the same as "Condor Albatross Eagle Birdie Par 0Bogey Double0Bogey Triple0Bogey"
using string compression and string interpolation. We then split on spaces, using ð¡
.
Part 3:
“Haha€î loser“ # Push "Haha you loser"
X # Push X
0¹1Qm # Compute 0 ^ (score == 1), this translates 1 to 0 and
everything else to 1.
* # Multiply the top two items
@ # Get the string from that position
0ð: # Replace zeros with spaces
ðÛ # Trim off leading spaces
Discovered a lot of bugs, uses CP-1252 encoding.
Try it online!
Vitsy, 131 bytes
D1-)["eno ni eloH"rZ;]r-5+D9/([X9]mZ
"rodnoC"
"ssortablA"
"elgaE"
"eidriB"
"raP"
"yegoB"
4m" elbuoD"
4m" elpirT"
"resol uoy ahaH"
Explanation:
D1-)["eno ni eloH"rZ;]r-5+D9/([X9]mZ
D1-)[ ] If the second input is 1, do the bracketed stuff.
"eno ni eloH"rZ; Output "Hole in one" and quit.
r Reverse the stack.
- Subtract the top two items.
5+ Add 5 to fix for negative values of score.
D9/([ ] If the result of that is greater than 8, do the stuff in brackets.
X Remove the top item.
9 Push 9. This forces any items greater than 8 to be 9.
m Execute this number line.
Z Output everything in the stack.
This works by figuring out what the score is relative to the par, then executing different lines (and gaining different strings) thereof.
Try It Online!
Verbose Mode (for poops and giggles):
duplicate top item;
push 1;
subtract top two;
if (int) top is not 0;
begin recursive area;
toggle double quote;
push 14;
eval(stack);
capture stack as object with next;
;
eval(stack);
push input item;
;
push 14;
push length of stack;
capture stack as object with next;
push all ints between second to top and top;
toggle double quote;
reverse stack;
output stack as chars;
generic exit;
end recursive area;
reverse stack;
subtract top two;
push 5;
add top two;
duplicate top item;
push 9;
divide top two;
if (int) top is 0;
begin recursive area;
remove top;
push 9;
end recursive area;
goto top method;
output stack as chars;
:toggle double quote;
reverse stack;
capture stack as object with next;
push 13;
eval(stack);
capture stack as object with next;
push cosine of top;
toggle double quote;
:toggle double quote;
push inverse sine of top;
push inverse sine of top;
capture stack as object with next;
reverse stack;
push inverse tangent of top;
push 10;
push 11;
push length of stack;
push inverse cosine of top;
toggle double quote;
:toggle double quote;
push 14;
push length of stack;
g;
push 10;
push e;
toggle double quote;
:toggle double quote;
push 14;
push input item;
push 13;
reverse stack;
push input item;
B;
toggle double quote;
:toggle double quote;
reverse stack;
push 10;
push pi;
toggle double quote;
:toggle double quote;
push number of stacks;
push 14;
g;
capture stack as object with next;
B;
toggle double quote;
:push 4;
goto top method;
toggle double quote;
;
push 14;
push length of stack;
push 11;
flatten top two stacks;
capture stack as object with next;
duplicate top item;
toggle double quote;
:push 4;
goto top method;
toggle double quote;
;
push 14;
push length of stack;
push whether (int) top item is prime;
push input item;
reverse stack;
push tangent of top;
toggle double quote;
;
;
:toggle double quote;
reverse stack;
push 14;
push inverse sine of top;
capture stack as object with next;
push length of stack;
;
flatten top two stacks;
capture stack as object with next;
push number of stacks;
;
push 10;
factorize top item;
push 10;
push all ints between second to top and top;
toggle double quote;