Skip to main content
added 362 characters in body
Source Link
Martin Ender
  • 197.2k
  • 67
  • 447
  • 975

Jelly, 6 bytes

S÷@×"S

or

÷S$×"S

Input is via two command-line arguments, masses first, coordinates second.

Try it online!

Explanation

S       Sum the masses.
   x"   Multiply each vector by the corresponding mass.
 ÷@     Divide the results by the sum of masses.
     S  Sum the vectors.

or

÷S$     Divide the masses by their sum.
   ×"   Multiply each vector by the corresponding normalised mass.
     S  Sum the vectors.

Jelly, 6 bytes

S÷@×"S

or

÷S$×"S

Input is via two command-line arguments, masses first, coordinates second.

Try it online!

Jelly, 6 bytes

S÷@×"S

or

÷S$×"S

Input is via two command-line arguments, masses first, coordinates second.

Try it online!

Explanation

S       Sum the masses.
   x"   Multiply each vector by the corresponding mass.
 ÷@     Divide the results by the sum of masses.
     S  Sum the vectors.

or

÷S$     Divide the masses by their sum.
   ×"   Multiply each vector by the corresponding normalised mass.
     S  Sum the vectors.
added 17 characters in body
Source Link
Martin Ender
  • 197.2k
  • 67
  • 447
  • 975

Jelly, 6 bytes

S÷@×"S

or

÷S$×"S

Input is via two command-line arguments, masses first, coordinates second.

Try it online!

Jelly, 6 bytes

S÷@×"S

Input is via two command-line arguments, masses first, coordinates second.

Try it online!

Jelly, 6 bytes

S÷@×"S

or

÷S$×"S

Input is via two command-line arguments, masses first, coordinates second.

Try it online!

Source Link
Martin Ender
  • 197.2k
  • 67
  • 447
  • 975

Jelly, 6 bytes

S÷@×"S

Input is via two command-line arguments, masses first, coordinates second.

Try it online!