# What is the standard scratch?

In golf, the standard scratch of a course is calculated using this formula:

(3*num_of_3_par_holes + 4*num_of_4_par_holes + 5*num_of_5_par_holes) - difficulty_rating


Your task is to calculate the standard scratch of a golf course, given these 4 inputs.

You should take input in any standard form in the format

[num_of_3_pars, num_of_4_pars, num_of_5_pars], difficulty rating


but if it saves bytes, you many take input in a different way.

You should output the final result by any accepted method on meta, such as returning from a function.

Shortest code wins because this is !

• Will all inputs be integers and at least 1? (Also, will the output always be positive?) – Doorknob Jul 5 '17 at 15:20
• Can we take inputs reversed? – totallyhuman Jul 5 '17 at 15:20
• As trivial as this is, a few test cases would be nice. – Dennis Jul 5 '17 at 16:20
• Interesting, a code golf about golf. – sergiol Jul 6 '17 at 0:07

# GolfScript, 23 bytes

~[.;3,]zip{~3+*}%{+}*\-


Try it online!

Takes input as difficulty rating [num_of_3_pars num_of_4_pars num_of_5_pars].

# PHP>=7.1, 43 bytes

[,$x,$y,$z,$d]=$argv;echo$x*3+$y*4+$z*5-$d;  PHP Sandbox Online # Pyth, 9 bytes -s*V}3 5E  Try it here. Takes input as difficulty rating\n[num_of_3_pars, num_of_4_pars, num_of_5_pars]. • The code you posted and the TIO don't match. – jacoblaw Jul 5 '17 at 16:41 • @jacoblaw Sorry that's what you get for writing code by hand >_< – Erik the Outgolfer Jul 5 '17 at 16:43 # CJam, 12 bytes {6,3>.*:+\-}  Try it online! -1 thanks to Challenger5. Takes input as difficulty rating [num_of_3_pars num_of_4_pars num_of_5_pars]. • Use 6,3> instead of 345Ab to save a byte. – Esolanging Fruit Jul 5 '17 at 16:54 # Batch, 28 bytes @cmd/cset/a%1*3+%2*4+%3*5-%4  Can't believe I'm tying with Python! • Just curious, do you need the cmd/c - if the rest is in a batch file won't it just work? – Jerry Jeremiah Jul 6 '17 at 1:28 • @JerryJeremiah set/a normally doesn't print its result, so I would have to assign it to a variable and echo it, which costs far too many bytes. However, when you use it interactively then it does print the result. Invoking cmd/c fools it into printing the result. – Neil Jul 6 '17 at 7:53 • Would the rules require the @ sign, which only hides the command? – trlkly Jul 6 '17 at 11:20 • @trlkly I'm not actually sure, so I've been erring on the side of caution. – Neil Jul 6 '17 at 14:08 # QBIC, 14 bytes ?:*3+:*4+:*5-:  Functionally equivalent to this. # MATL, 7 bytes 3:5*si-  Try it online! Input vector times range 3:5 minus the second input. Contrary to my Octave answer, it's actually shorter to have the inputs as two separate inputs, and shorter to element-wise multiply, then sum, than to do a direct dot product. # cQuents, 14 bytes #|1:3A+4B+5C-D  Try it online! Input is 3par 4par 5par diff. cQuents is not at all built for this type of problem, but it still did fairly well. ## Explanation #|1 Append 1 to the end of the user input - call it n : Mode: sequence 3A+4B+5C-D Each item in the sequence equals the first input times three plus the second input times four plus the third input times five minus the fourth input. The last input, n, which came from the program's parameters, prints the nth item in the sequece.  # Pyt, 13 8 bytes 35Ř←*Ʃ←-  Takes as input from stdin inputs separately in the following order: [num_of_3_pars,num_of_4_pars,num_of_5_pars], difficulty_rating # TI-Basic, 19 bytes Prompt A,B,C,D:3A+4B+5C-D  Alternatively (21 bytes): 3Ans(1)+4Ans(2)+5Ans(3)-Ans(4  # Add++, 27 bytes D,g,@@@@!,3 4 5 1ECBcB*0$_s


Try it online!

## How it works

D,g,        - Create a function called g...
@@@@    - ...that takes 4 arguments...
!,      - ...as a list. e.g.     [4 3 2 1]
3 4 5 1 - Push 3 4 5 1; STACK = [[4 3 2 1] 3 4 5 1]
EC      - Collect;      STACK = [[4 3 2 1] [3 4 5 1]]
Bc      - Zip;          STACK = [[4 3] [3 4] [2 5] [1 1]]
B*      - Products;     STACK = [12 12 10 1]
0\$_     - Negate;       STACK = [12 12 10 -1]
s       - Sum;          STACK = [33]


# Ly, 13 bytes

3n*4n*5n*&+n-


Try it online!