g | x | w | all
Bytes Lang Time Link
009Japt x170705T150946ZShaggy
037Scratch170705T232515ZLaurel
011Emacs calc250330T175922Zbindiff
020AWK250330T001037Zxrs
007Vyxal as210519T043412Za stone
013Julia 1.0210520T143847ZMarcMush
018BRASCA210519T125115ZSjoerdPe
022Factor210519T152814Zchunes
246MMIX210519T044839ZNoLonger
024Javascript170705T150510ZSuperSto
012K ngn/k201229T210743Zcoltim
066PHP201017T222256ZZsolt Sz
009Husk201016T201417ZLegionMa
013Stax201017T155855ZRazetime
021Desmos201016T203329ZAiden Ch
023R170706T185213ZGiuseppe
008Pyt171225T033914Zmudkip20
020Excel VBA170706T184843ZTaylor R
013Ly171122T090110ZLyricLy
027Add++171120T212908Zcaird co
019TIBasic171120T212614ZTimtech
014cQuents170705T152010ZStephen
007MATL170706T174259ZSanchise
014QBIC170707T092331Zsteenber
014Octave170706T174600ZSanchise
014HP15C RPN170707T020855ZRyan
036Cubix170706T192107ZMickyT
012170705T163643Ztotallyh
007Jelly170705T150409Zcaird co
016Brachylog170705T180710ZErik the
014dc170706T121657Zmanatwor
038Gallina170706T120200ZBiv
014x8664 Machine Code170706T105837ZCody Gra
028Batch170705T151954ZNeil
039brainfuck170706T014640Zmusicman
006Jelly170705T161926ZDennis
1314Mathematica170705T150716ZKeyu Gan
012CJam170705T154429ZErik the
009Pyth170705T160329ZErik the
043PHP>=7.1170705T163637ZJör
015Julia 0.5170705T163443ZDennis
019Swift 3170705T151928ZMr. Xcod
023GolfScript170705T161758ZErik the
022Haskell170705T161636ZLaikoni
030C gcc170705T155159ZGiacomo
007Neim170705T153718ZOkx
00705AB1E170705T153149ZErik the
024C#170705T152810ZTheLetha
016Perl6170705T152626Zmanatwor
021Julia170705T151612ZJulian W
014Braingolf170705T151454ZMayube
024Java OpenJDK 8170705T150842ZOlivier
015Befunge170705T150709Zovs
028Python 3170705T150352Znotjagan

Japt -x, 12 9 bytes

Takes input as:

[difficulty rating, num_of_3_pars, num_of_4_pars, num_of_5_pars]

Includes an unprintable after the #.

í*#5ì)vn

Try it

Scratch, 40 37 Norwegian bytes

-2 thanks to boboquack
-1 because "si" (Norwegian) is shorter than "say". Another (same length) option was Haitian Creole.

(Because Scratch is the standard scratch.)

si(((c)-((a)+(d)))+((4)*(((a)+(b))+(c

Orange blocks are variables. Here's a sample run:

a=18,b=13,c=41,d=23;answer=124.

Emacs calc, 11 bytes

Setup this on the stack:

1:  difficulty rating
2:  [num_of_3_pars, num_of_4_pars, num_of_5_pars]

Keypresses:

'[3,4,5 <Ret> * <Tab> -

AWK, 20 bytes

$0=3*$1+4*$2+5*$3-$4

Attempt This Online!

Noticed this interesting mathematical pattern:

Repeat input, repeat output

Vyxal as, 8 7 bytes

-1 thanks to Aaron Miller

2ʀ3+uJ*

Takes input as par3 \n par4 \n par5 \n difficulty. Try it Online!

2ʀ3+uJ*
2ʀ        # Push the range [0, 1, 2]
  3+      # Add 3: [3, 4, 5]
    uJ    # Append -1: [3, 4, 5, -1]
      *   # Multiply the list by its counterpart in...
          # the (implicit) input, and...
          # Print the sum of the result (s flag) 

Julia 1.0, 13 bytes

v->[3:5;-1]'v

Try it online!

improvement of Dennis's Julia 0.5 answer

BRASCA, 18 bytes

Takes input as <3-par>,<4-par>,<5-par>,<difficulty>

Ci',G,3*$4*+$5*+$-

Try it online!

Explanation

C                   - Set implicit output to number mode
 i',G               - Use numbers instead of charcodes for 0-9. Then split by commas.
     ,              - Reverse stack so the 3par is at the top.
      3*            - 3par * 3
        $4*+        - 4par * 4, then add to 3par
            $5*+    - 5par * 5, then add to total
                $-  - total - difficulty
<implicit>          - Print it

Factor, 23 22 bytes

[ { 3 4 5 } v. - neg ]

Try it online!

-1 thanks to @Bubbler

The quotation takes the input as difficulty list.

MMIX, 24 bytes (6 instrs)

00000000: 2a020202 28000000 26020203 2a000100  *£££(¡¡¡&££¤*¡¢¡
00000010: 22000002 f8010000                    "¡¡£ẏ¢¡¡
scratch 4ADDU $2,$2,$2      // p5 *= 5
        2ADDU $0,$0,$0      // p3 *= 3
        SUBU  $2,$2,$3      // p5 -= diff
        4ADDU $0,$1,$0      // p3 += 4 * p4
        ADDU  $0,$0,$2      // p3 += p5
        POP   1,0           // return p3

I ordered the instructions to avoid as many short-term data dependencies as possible.

Javascript, 24 bytes

(a,b,c,d)=>3*a+4*b+5*c-d

K (ngn/k), 12 bytes

{-y-/x*3+!3}

Try it online!

Called like f[1 2 3;4]. Takes the number of par 3/4/5 holes as one list of three values, and the difficulty rating as the second arg.

PHP, 66 bytes

list($a,$b,$c,$d,$e)=$argv;echo eval("return 3*$b+4*$c+5*$d-$e;");


first attempt:

PHP, 145 bytes

<?php $a=$_SERVER['argv'];$b=[0,3,4,5,-1];$r=array_map(function($x,$y){return$x*$y;},$a,$b);echo array_reduce($r,function($i,$c){return$i+=$c;});

Ungolfed:

<?php
$a = $_SERVER['argv'];
$b = [0,3,4,5,-1]; // the first element always contains the filename, and is hereby disregarded
$r = array_map(function($x,$y){return $x*$y;},$a,$b);
echo array_reduce($r, function ($i,$c) {return $i+=$c;});


With 10, 5 and 3 holes respectivly, and a difficulty of 5, it's to be called with $ php codegolf.php 10 5 3 5

Note: it throws a warning, as we multiply a string with zero. Add 1 byte for the error-supression-operator to get rid if that.

Husk, 10 9 bytes

`-Σz*d345

Try it online!

Stax, 13 bytes

╨E⌡u╥Diüaë¬~▼

Run and debug it

If I can find a way to read in the array and the number as is instead of evaluating them from string, this program will be shorter.

Desmos, 21 bytes

f(a,b,c,d)=3a+4b+5c-d

Try It On Desmos!

Input is a function where \$a=3\ \text{par holes},b=4\ \text{par holes},c=5\ \text{par holes},d=\text{difficulty rating}\$

Example Test Case:

R, 25 23 bytes

cat(c(3:5,-1)%*%scan())

Try it online!

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

Excel VBA, 20 Bytes

Anonymous VBE immediate window function that takes input from the range [A3:A6] of which [A3:A5] represent the number of 3,4 and 5 par holes, respectively and [A6] represents the difficulty. Outputs to the VBE immediate window

?[3*A3+4*A4+5*A5-A6]

The above is a condensed version of the call

Debug.Print Application.Evaluate("=3*A3+4*A4+5*A5-A6")

Where "=3*A3+4*A4+5*A5-A6" is given to be the formula of an anonymous cell, as indicated by the [...] wrapper, and ? is the deprecated version of the Print call with an implicit Debug. by context

More fun Version, 34 Bytes

Anonymous VBE immediate window function with same I/O conditions as above.

?[SUMPRODUCT(A3:A5,ROW(A3:A5))-A6]

The above is a condensed version of the call

Debug.Print Application.Evaluate("=SUMPRODUCT(A3:A5,ROW(A3:A5))")

Where "=SUMPRODUCT(A3:A5,ROW(A3:A5))" is given to be the formula of an anonymous cell, as indicated by the [...] wrapper, and ? is the deprecated version of the Print call with an implicit Debug. by context. In this version, the range of [A3:A5] and the row numbers of that range (ROWS(A3:A5)) are passed as arrays

Excel Version, 18 bytes

Of course, the versions above lend themselves thusly to excel versions of

=3*A3+4*A4+5*A5-A6

and

=SUMPRODUCT(A3:A5,ROW(A3:A5))-A6

Ly, 13 bytes

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

Try it online!

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]

TI-Basic, 19 bytes

Prompt A,B,C,D:3A+4B+5C-D

Alternatively (21 bytes):

3Ans(1)+4Ans(2)+5Ans(3)-Ans(4

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.
                  

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.

QBIC, 14 bytes

?:*3+:*4+:*5-:

Functionally equivalent to this.

Octave, 14 bytes

@(a)[3:5 -1]*a

Try it online!

About twice as long as the MATL answer. I initially literally ported this to MATL, but it turned out iY* is longer than just *s. Note that the input a, containing the holes in order and then the difficulty, should be a column vector.

HP-15C (RPN), 14 bytes

Instruction hex codes:

41 C4 F5 FC C5 F4 FC FA C5 F3 FC FA 31 FB

Readable version:

001 {       44  1 } STO 1
002 {          33 } R⬇
003 {           5 } 5
004 {          20 } ×
005 {          34 } x↔y
006 {           4 } 4
007 {          20 } ×
008 {          40 } +
009 {          34 } x↔y
010 {           3 } 3
011 {          20 } ×
012 {          40 } +
013 {       45  1 } RCL 1
014 {          30 } −

The four numbers are loaded into the stack in order before running the program.

Cubix, 36 bytes

w;r5*U4I;I3*r;UW;;r;<\r/;r-I/+p+O@;w

Try it online!

      w ; r
      5 * U
      4 I ;
I 3 * r ; U W ; ; r ; <
\ r / ; r - I / + p + O
@ ; w . . . . . . . . .
      . . .
      . . .
      . . .

Watch It Run

A fairly linear program that winds back around onto itself a few times. Basic steps:

,,,, 12 bytes

↻5×↻4×↻3×↻-#

Explanation

Take input 4, 3, 2, 1 for example.

↻5×↻4×↻3×↻-#

              implicit input                  [4, 3, 2, 1]
↻             rotate the stack clockwise      [1, 4, 3, 2]
 5            push 5                          [1, 4, 3, 2, 5]
  ×           pop 2 and 5 and push 2 * 5      [1, 4, 3, 10]
   ↻          rotate the stack clockwise      [10, 1, 4, 3]
    4         push 4                          [10, 1, 4, 3, 4]
     ×        pop 3 and 4 and push 3 * 4      [10, 1, 4, 12]
      ↻       rotate the stack clockwise      [12, 10, 1, 4]
       3      push 3                          [12, 10, 1, 4, 3]
        ×     pop 4 and 3 and push 4 * 3      [12, 10, 1, 12]
         ↻    rotate the stack clockwise      [12, 12, 10, 1]
          -   pop 10 and 1 and push 10 - 1    [12, 12, 9]
           #  pop 12, 12, 9 and push the sum  [33]
              implicit output

Jelly, 10 7 bytes

3r5×⁸S_

Try it online!

-3 bytes thanks to Erik The Outgolfer!

How it works!

3r5×⁸S_  Main link: a, the pars as a list and b, the difficulty rating

     S   The sum of
3r5        [3, 4, 5]
   ×       each element times
    ⁸      the left argument (a)
      _  Subtract the right argument (b)

Brachylog, 18 16 bytes

∧5⟦₁↺b;?z×ᵐġ₃+ᵐ-

Try it online!

-2 thanks to Fatalize.

dc, 14 characters

?3*?4*+?5*+?-p

The numbers need to be passed on separate lines.

Sample run:

bash-4.4$ dc -e '?3*?4*+?5*+?-p' <<< '4
> 3
> 2
> 1'
33

Try it online!

Gallina, 38 bytes

Definition f a b c d := 3*a+4*b+5*c-d.

x86-64 Machine Code, 14 bytes

8D 3C 7F 8D 14 92 8D 04 B7 01 D0 29 C8 C3

A function following the System V AMD64 calling convention (ubiquitous on Gnu/Linux systems) that takes four integer parameters:

It returns a single value, the standard scratch, in the EAX register.

Ungolfed assembly mnemonics:

; int ComputeStandardScratch(int num_of_3_par_holes,
;                            int num_of_4_par_holes,
;                            int num_of_5_par_holes,
;                            int difficulty_rating);
lea   edi, [rdi+rdi*2]    ; EDI = num_of_3_par_holes * 3
lea   edx, [rdx+rdx*4]    ; EDX = num_of_5_par_holes * 5
lea   eax, [rdi+rsi*4]    ; EAX = EDI + (num_of_4_par_holes * 4)
add   eax, edx            ; EAX += EDX
sub   eax, ecx            ; EAX -= difficulty_rating
ret                       ; return, leaving result in EAX

Just a simple translation of the formula. What's interesting is that this is essentially the same code that you would write when optimizing for speed, too. This really shows the power of the x86's LEA instruction, which is designed to load an effective address, but can do addition and scaling (multiplication by low powers of 2) in a single instruction, making it a powerful multi-purpose arithmetic workhorse.

Batch, 28 bytes

@cmd/cset/a%1*3+%2*4+%3*5-%4

Can't believe I'm tying with Python!

brainfuck, 39 bytes

,[->+++<],[->++++<],[->+++++<],[->-<]>.

Try it online!

Takes input and prints output as ASCII characters; for example, the value 99 would be represented as c.

Explanation:

,                                       Take the first input in Cell 0
 [      ]                               While the data being pointed to (Cell 0) is nonzero
  ->+++<                                Decrement Cell 0 and add 3 to Cell 1
                                        Now 4 times the first input is in Cell 1
         ,                              Take the second input in Cell 0
          [->++++<]                     Add 4 times the second input to Cell 1
                   ,[->+++++<]          Take the third input in Cell 0 and add five times its value to Cell 1
                              ,         Take the fourth input in Cell 0
                               [    ]   While the data being pointed to (Cell 0) is nonzero
                                ->-<    Decrement Cells 0 and 1
                                     >. Print the value in Cell 1

Jelly, 6 bytes

JḊ~æ.N

Try it online!

How it works

JḊ~æ.N  Main link. Argument: [a, b, c, d]

J       Indices; yield [1, 2, 3, 4].
 Ḋ      Dequeue; yield [2, 3, 4].
  ~     Bitwise NOT; yield [-3, -4, -5].
     N  Negate; yield [-a, -b, -c, -d].
   æ.   Dot product; yield
        (-3)(-a) + (-4)(-b) + (-5)(-c) + (-d) = 3a + 4b + 5c - d.

Mathematica, 13 14 bytes

{3,4,5,-1}.#&

Thanks to @GregMartin. Take input as a length-4 list.

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].

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].

PHP>=7.1, 43 bytes

[,$x,$y,$z,$d]=$argv;echo$x*3+$y*4+$z*5-$d;

PHP Sandbox Online

Julia 0.5, 15 bytes

!v=v⋅[3:5;-1]

Try it online!

Swift 3, 25 19 bytes

I realised you do not need the var f=, because you can call it like a Python lambda:

{$0*3+$1*4+$2*5-$3}

Test it online!

Usage: {$0*3+$1*4+$2*5-$3}(a,b,c,d), where a,b,c,d are the parameters.

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].

Haskell, 22 bytes

(a#b)c d=3*a+4*b+5*c-d

Try it online! Usage: (3#2)5 7 yields 35.

This not so nice input format is one byte shorter than the straight forward solution:

f a b c d=3*a+4*b+5*c-d

Point-free and nice input format: (23 bytes)

(-).sum.zipWith(*)[3..]

Try it online! Bind to f and call with f [3,2,5] 7.

C (gcc), 30 bytes

e;f(a,b,c,d){e=3*a+4*b+5*c-d;}

Try it online!

Neim, 7 bytes

'π𝐂𝕋𝐬S𝕊

Explanation:

'π         Push 345
           The character ' pushes the next character's index in the codepage plus 100.
           The characters ", + and * do that same thing except add a different number.
           This means that in Neim, all 3 digit numbers can be expressed with 2 characters.
           This commit was pushed 8 days before the answer was posted.
  𝐂        Get the characters
   𝕋       Vectorised multiply with the input
    𝐬       Sum the resulting list
     S𝕊    Subtract the input

Alternative program: 3𝐈ᛖ𝕋𝐬S𝕊

Instead of pushing 345 and then getting the characters, creates the array [1 2 3] using 3𝐈, then adds 2 to each element with .

Try it online!

05AB1E, 7 bytes

3LÌ*O²-

Try it online!

C#, 24 bytes

(a,b,c,d)=>a*3+b*4+c*5-d

Perl6, 16 characters

3* *+4* *+5* *-*

(Yepp, that is a sub.)

Sample run:

> say 3* *+4* *+5* *-*
{ ... }

> say (3* *+4* *+5* *-*)(4, 3, 2, 1)
33

Try it online!

Julia, 21 bytes

f(a,b,c,d)=3a+4b+5c-d

Try it online!

Braingolf, 14 bytes

3*>4*>5*>>++,-

Try it online!

Java (OpenJDK 8), 24 bytes

(a,b,c,d)->a*3+b*4+c*5-d

Try it online!

Befunge, 15 bytes

&3*&4*+&5*+&-.@

Try it online!

Python 3, 28 bytes

lambda a,b,c,d:3*a+4*b+5*c-d

Try it online!