Skip to main content
deleted 14 characters in body
Source Link
Noodle9
  • 20.3k
  • 3
  • 21
  • 46

C++ (clang)C++ (gcc), 280 \$\cdots\$ 212211 211210 bytes

#import<regex>
#define S(v)std::sort(&v[0],&*end(v))
using V=std::vector<int>;voidvector<int>;int f(V&v){V r=v,x;S(v);int m=v.back(),n=m,t;for(int a:r)for(int b:r)for(int c:r)x={a,b,c},S(x),t=x[2]-x[0],v=t<m&a+b+c==n?m=t,x:v;}

Try it online!Try it online!

Saved 3 4 bytes thanks to ceilingcat!!!

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

C++ (clang), 280 \$\cdots\$ 212 211 bytes

#import<regex>
#define S(v)std::sort(&v[0],&*end(v))
using V=std::vector<int>;void f(V&v){V r=v,x;S(v);int m=v.back(),n=m,t;for(int a:r)for(int b:r)for(int c:r)x={a,b,c},S(x),t=x[2]-x[0],v=t<m&a+b+c==n?m=t,x:v;}

Try it online!

Saved 3 4 bytes thanks to ceilingcat!!!

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

C++ (gcc), 280 \$\cdots\$ 211 210 bytes

#import<regex>
#define S(v)std::sort(&v[0],&*end(v))
using V=std::vector<int>;int f(V&v){V r=v,x;S(v);int m=v.back(),n=m,t;for(int a:r)for(int b:r)for(int c:r)x={a,b,c},S(x),t=x[2]-x[0],v=t<m&a+b+c==n?m=t,x:v;}

Try it online!

Saved 3 4 bytes thanks to ceilingcat!!!

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

added 8 characters in body
Source Link
Noodle9
  • 20.3k
  • 3
  • 21
  • 46

C++ (clang), 280 \$\cdots\$ 217212 212211 bytes

#import<regex>
#define S(v)std::sort(&v[0],&*end(v));
using V=std::vector<int>;void f(V&v){V r=v;Sr=v,x;S(v)int;int m=v.back(),n=m,t;for(int a:r)for(int b:r)for(int c:r){V x={a,b,c};S,S(x),t=x[2]-x[0];v=t<m&a+b+c==nx[0],v=t<m&a+b+c==n?m=t,x:v;}}

Try it online!Try it online!

Saved 33 4 bytes thanks to ceilingcat!!!

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

C++ (clang), 280 \$\cdots\$ 217 212 bytes

#import<regex>
#define S(v)std::sort(&v[0],&*end(v));
using V=std::vector<int>;void f(V&v){V r=v;S(v)int m=v.back(),n=m,t;for(int a:r)for(int b:r)for(int c:r){V x={a,b,c};S(x)t=x[2]-x[0];v=t<m&a+b+c==n?m=t,x:v;}}

Try it online!

Saved 3 bytes thanks to ceilingcat!!!

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

C++ (clang), 280 \$\cdots\$ 212 211 bytes

#import<regex>
#define S(v)std::sort(&v[0],&*end(v))
using V=std::vector<int>;void f(V&v){V r=v,x;S(v);int m=v.back(),n=m,t;for(int a:r)for(int b:r)for(int c:r)x={a,b,c},S(x),t=x[2]-x[0],v=t<m&a+b+c==n?m=t,x:v;}

Try it online!

Saved 3 4 bytes thanks to ceilingcat!!!

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

deleted 8 characters in body
Source Link
Noodle9
  • 20.3k
  • 3
  • 21
  • 46

C++ (clang), 280 \$\cdots\$ 217 212 bytes

#import<regex>
#define S(v)std::sort(&v[0],&*end(v));
using V=std::vector<int>;void f(V&v){V r=v;S(v)int m=v.back(),n=m,t;for(int a:r)for(int b:r)for(int c:r){V x={a,b,c};S(x)t=x[2]-x[0];v=t<m&a+b+c==n?m=t,x:v;}}

Try it online!

Saved 3 bytes thanks to ceilingcat!!!

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

C++ (clang), 280 \$\cdots\$ 217 212 bytes

#import<regex>
#define S(v)std::sort(&v[0],&*end(v));
using V=std::vector<int>;void f(V&v){V r=v;S(v)int m=v.back(),n=m,t;for(int a:r)for(int b:r)for(int c:r){V x={a,b,c};S(x)t=x[2]-x[0];v=t<m&a+b+c==n?m=t,x:v;}}

Try it online!

Saved 3 bytes thanks to ceilingcat!!!

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

C++ (clang), 280 \$\cdots\$ 217 212 bytes

#import<regex>
#define S(v)std::sort(&v[0],&*end(v));
using V=std::vector<int>;void f(V&v){V r=v;S(v)int m=v.back(),n=m,t;for(int a:r)for(int b:r)for(int c:r){V x={a,b,c};S(x)t=x[2]-x[0];v=t<m&a+b+c==n?m=t,x:v;}}

Try it online!

Saved 3 bytes thanks to ceilingcat!!!

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

deleted 8 characters in body
Source Link
Noodle9
  • 20.3k
  • 3
  • 21
  • 46
Loading
edited body
Source Link
Noodle9
  • 20.3k
  • 3
  • 21
  • 46
Loading
added 11 characters in body
Source Link
Noodle9
  • 20.3k
  • 3
  • 21
  • 46
Loading
deleted 67 characters in body
Source Link
Noodle9
  • 20.3k
  • 3
  • 21
  • 46
Loading
deleted 29 characters in body
Source Link
Noodle9
  • 20.3k
  • 3
  • 21
  • 46
Loading
added 28 characters in body
Source Link
Noodle9
  • 20.3k
  • 3
  • 21
  • 46
Loading
Rollback to Revision 2
Source Link
Noodle9
  • 20.3k
  • 3
  • 21
  • 46
Loading
added 109 characters in body
Source Link
Noodle9
  • 20.3k
  • 3
  • 21
  • 46
Loading
deleted 16 characters in body
Source Link
Noodle9
  • 20.3k
  • 3
  • 21
  • 46
Loading
added 96 characters in body
Source Link
Noodle9
  • 20.3k
  • 3
  • 21
  • 46
Loading
added 268 characters in body
Source Link
Noodle9
  • 20.3k
  • 3
  • 21
  • 46
Loading
Source Link
Noodle9
  • 20.3k
  • 3
  • 21
  • 46
Loading