Skip to main content
7 of 15
added 28 characters in body
Noodle9
  • 20.3k
  • 3
  • 21
  • 46

C++ (clang), 280 \$\cdots\$ 269 266 bytes

#import<regex>
#define S(v)sort(&v[0],&*end(v));
using namespace std;using V=vector<int>;V f(V&v){vector<V>w;map<int,int>m;S(v)for(int a:v)for(int b:v)for(int c:v)if(a+b+c==v.back()){V x={a,b,c};S(x)m[x[2]-x[0]]=w.size();w.push_back(x);}return w[m.begin()->second];}

Try it online!

Saved 3 bytes thanks to ceilingcat!!!

Inputs a vector of integers.
Returns the vector with the minimum difference between the smallest and the largest element from all the cartesian products of 3 elements that add up to the maximum of the input vector.

Noodle9
  • 20.3k
  • 3
  • 21
  • 46