Skip to main content
deleted 6 characters in body
Source Link
tsh
  • 35.5k
  • 2
  • 34
  • 129

Python 3, 9795 bytes

f=lambda t,a,*p:t==0<len[p][t*t:len(p)==5and{p}or==5]or{i for v in[*a]for i in f(t-a.pop(0),[*a],*sorted([*p,v]))}

Try it online!Try it online!

Input target value and the array of nums, output a set of tuples.

Python 3, 97 bytes

f=lambda t,a,*p:t==0<len(p)==5and{p}or{i for v in[*a]for i in f(t-a.pop(0),[*a],*sorted([*p,v]))}

Try it online!

Input target value and the array of nums, output a set of tuples.

Python 3, 95 bytes

f=lambda t,a,*p:[p][t*t:len(p)==5]or{i for v in[*a]for i in f(t-a.pop(0),[*a],*sorted([*p,v]))}

Try it online!

Input target value and the array of nums, output a set of tuples.

deleted 12 characters in body
Source Link
tsh
  • 35.5k
  • 2
  • 34
  • 129

Python 3, 10097 bytes

f=lambda t,a,*p:t==0<len(p)==5and{p}or{*sum([[*fi for v in[*a]for i in f(t-a.pop(0),[*a],*sorted([*p,v]))]for v in[*a]],[])}

Try it online!Try it online!

Input target value and the array of nums, output a set of tuples.

Python 3, 100 bytes

f=lambda t,a,*p:t==0<len(p)==5and{p}or{*sum([[*f(t-a.pop(0),[*a],*sorted([*p,v]))]for v in[*a]],[])}

Try it online!

Python 3, 97 bytes

f=lambda t,a,*p:t==0<len(p)==5and{p}or{i for v in[*a]for i in f(t-a.pop(0),[*a],*sorted([*p,v]))}

Try it online!

Input target value and the array of nums, output a set of tuples.

Source Link
tsh
  • 35.5k
  • 2
  • 34
  • 129

Python 3, 100 bytes

f=lambda t,a,*p:t==0<len(p)==5and{p}or{*sum([[*f(t-a.pop(0),[*a],*sorted([*p,v]))]for v in[*a]],[])}

Try it online!