Skip to main content
deleted 2 characters in body
Source Link
Jonathan Allan
  • 110.1k
  • 7
  • 65
  • 282

Jelly, 4? 8 bytes

With a strict interpretation of Rule 1 (can't take as a program argument due to the "single line" part) - a full program that reads from STDIN and writes to STDOUT:

ɠḲVµS÷4_

Try it online!

...or with site default IO instead - a monadic Link that accepts a list of five numbers and yields a list of five numbers:

S÷4_

Try it online!

How?

ɠḲVµS÷4_ - Main Link: no arguments
ɠ        - read a line from STDIN
 Ḳ       - split that at spaces
  V      - evaluate that as Jelly code -> list of the five four-apple-weights, W
   µ     - start a new monadic chain - f(W)
    S    - sum W
      4  - four
     ÷   - divide -> sum(W)/4
       _ - subtract W (vectorises) -> [w1-sum[sum(W)/4-w1, w2-sum(W)/4-w2, w3-sum(W)/4-w3, w4-sum(W)/4-w4, w5-sum(W)/4, ]-w5]
         - implicit print

Jelly, 4? 8 bytes

With a strict interpretation of Rule 1 (can't take as a program argument due to the "single line" part):

ɠḲVµS÷4_

Try it online!

...or with site default IO instead:

S÷4_

Try it online!

How?

ɠḲVµS÷4_ - Main Link: no arguments
ɠ        - read a line from STDIN
 Ḳ       - split that at spaces
  V      - evaluate that as Jelly code -> list of the five four-apple-weights, W
   µ     - start a new monadic chain - f(W)
    S    - sum W
      4  - four
     ÷   - divide -> sum(W)/4
       _ - subtract (vectorises) -> [w1-sum(W)/4, w2-sum(W)/4, w3-sum(W)/4, w4-sum(W)/4, w5-sum(W)/4, ]
         - implicit print

Jelly, 4? 8 bytes

With a strict interpretation of Rule 1 (can't take as a program argument due to the "single line" part) - a full program that reads from STDIN and writes to STDOUT:

ɠḲVµS÷4_

Try it online!

...or with site default IO instead - a monadic Link that accepts a list of five numbers and yields a list of five numbers:

S÷4_

Try it online!

How?

ɠḲVµS÷4_ - Main Link: no arguments
ɠ        - read a line from STDIN
 Ḳ       - split that at spaces
  V      - evaluate that as Jelly code -> list of the five four-apple-weights, W
   µ     - start a new monadic chain - f(W)
    S    - sum W
      4  - four
     ÷   - divide -> sum(W)/4
       _ - subtract W (vectorises) -> [sum(W)/4-w1, sum(W)/4-w2, sum(W)/4-w3, sum(W)/4-w4, sum(W)/4-w5]
         - implicit print
Source Link
Jonathan Allan
  • 110.1k
  • 7
  • 65
  • 282

Jelly, 4? 8 bytes

With a strict interpretation of Rule 1 (can't take as a program argument due to the "single line" part):

ɠḲVµS÷4_

Try it online!

...or with site default IO instead:

S÷4_

Try it online!

How?

ɠḲVµS÷4_ - Main Link: no arguments
ɠ        - read a line from STDIN
 Ḳ       - split that at spaces
  V      - evaluate that as Jelly code -> list of the five four-apple-weights, W
   µ     - start a new monadic chain - f(W)
    S    - sum W
      4  - four
     ÷   - divide -> sum(W)/4
       _ - subtract (vectorises) -> [w1-sum(W)/4, w2-sum(W)/4, w3-sum(W)/4, w4-sum(W)/4, w5-sum(W)/4, ]
         - implicit print