Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

deleted 12 characters in body
Source Link
Jitse
  • 8.1k
  • 3
  • 21
  • 45

Python 3, 107106 bytes

def f(a,n=-1,x=0):a[n]-=x;return~-any(a)^any(f(a[:]1*a,i,j+1)for i,k in enumerate(a)for j in range(x,k)if i-n)

Try it online! Try it online!

Brute force search. Recursively subtracts a strictly increasing valuex from every indexi in the inputa, as long as iit is not equal to the lastprviously picked indexn. This continues until all values in athe input are zero or the options to continue are exhausted.

Python 3, 107 bytes

def f(a,n=-1,x=0):a[n]-=x;return~-any(a)^any(f(a[:],i,j+1)for i,k in enumerate(a)for j in range(x,k)if i-n)

Try it online!

Brute force search. Recursively subtracts a strictly increasing valuex from every indexi in the inputa, as long as i is not equal to the last picked indexn. This continues until all values in a are zero or the options to continue are exhausted.

Python 3, 106 bytes

def f(a,n=-1,x=0):a[n]-=x;return~-any(a)^any(f(1*a,i,j+1)for i,k in enumerate(a)for j in range(x,k)if i-n)

Try it online!

Brute force search. Recursively subtracts a strictly increasing value from every index in the input, as long as it is not equal to the prviously picked index. This continues until all values in the input are zero or the options to continue are exhausted.

deleted 11 characters in body
Source Link
Jitse
  • 8.1k
  • 3
  • 21
  • 45

Python 3, 111107 bytes

f=lambdadef f(a,n=-1,x=0):1a[n]-=x;return~-any(a)^any(f(a[:i]+[k+~j]+a[i+1:],i,j+1)for i,k in enumerate(a)for j in range(x,k)if i-n)

Try it online! Try it online!

Brute force search. Recursively subtracts a strictly increasing value x from every index i in the input a, as long as i is not equal to the last picked index n. This continues until all values in a are zero or the options to continue are exhausted.

Python 3, 111 bytes

f=lambda a,n=-1,x=0:1-any(a)^any(f(a[:i]+[k+~j]+a[i+1:],i,j+1)for i,k in enumerate(a)for j in range(x,k)if i-n)

Try it online!

Brute force search. Recursively subtracts a strictly increasing value x from every index i in the input a, as long as i is not equal to the last picked index n. This continues until all values in a are zero or the options to continue are exhausted.

Python 3, 107 bytes

def f(a,n=-1,x=0):a[n]-=x;return~-any(a)^any(f(a[:],i,j+1)for i,k in enumerate(a)for j in range(x,k)if i-n)

Try it online!

Brute force search. Recursively subtracts a strictly increasing value x from every index i in the input a, as long as i is not equal to the last picked index n. This continues until all values in a are zero or the options to continue are exhausted.

deleted 10 characters in body
Source Link
Jitse
  • 8.1k
  • 3
  • 21
  • 45

Python 3, 114111 bytes

f=lambda a,n=-1,x=0:~1-any(a)^any(f(a[:i]+[k+~j]+a[i+1:],i,j+1)for i,k in enumerate(a)for j in range(x,a[i]k)if i-n)

Try it online! Try it online!

Brute force search. Recursively subtracts a strictly increasing value x from every index i in the inputa, as long as i is not equal to the last picked index n. This continues until all values in a are zero or the possibilitiesoptions to continue are exhausted.

Python 3, 114 bytes

f=lambda a,n=-1,x=0:~-any(a)^any(f(a[:i]+[k+~j]+a[i+1:],i,j+1)for i,k in enumerate(a)for j in range(x,a[i])if i-n)

Try it online!

Brute force search. Recursively subtracts a strictly increasing value x from every index i in the input, as long as i is not equal to the last picked index n. This continues until all values in a are zero or the possibilities to continue are exhausted.

Python 3, 111 bytes

f=lambda a,n=-1,x=0:1-any(a)^any(f(a[:i]+[k+~j]+a[i+1:],i,j+1)for i,k in enumerate(a)for j in range(x,k)if i-n)

Try it online!

Brute force search. Recursively subtracts a strictly increasing value x from every index i in the inputa, as long as i is not equal to the last picked index n. This continues until all values in a are zero or the options to continue are exhausted.

added 136 characters in body
Source Link
Jitse
  • 8.1k
  • 3
  • 21
  • 45
Loading
deleted 3 characters in body
Source Link
Jitse
  • 8.1k
  • 3
  • 21
  • 45
Loading
Source Link
Jitse
  • 8.1k
  • 3
  • 21
  • 45
Loading

AltStyle によって変換されたページ (->オリジナル) /