Skip to main content
Commonmark migration
Source Link

##Python 2, 45 bytes

Python 2, 45 bytes

f=lambda l:l==[]or l[len(l)/2-1]/l.pop()*f(l)

Outputs 0 for Falsy, nonzero for Truthy.

Checks that the last element is less than or equal to its parent at index len(l)/2-1. Then, recurses to check that the same is True with the last element of the list removed, and so on until the list is empty.


48 bytes:

f=lambda l,i=1:l==l[:i]or l[~-i/2]/l[i]*f(l,i+1)

Checks that at each index i, the element is at most its parent at index (i-1)/2. The floor-division produces 0 if this is not the case.

Doing the base case as i/len(l)or gives the same length. I had tried zipping at first, but got longer code (57 bytes).

lambda l:all(map(lambda a,b,c:b<=a>=c,l,l[1::2],l[2::2]))

##Python 2, 45 bytes

f=lambda l:l==[]or l[len(l)/2-1]/l.pop()*f(l)

Outputs 0 for Falsy, nonzero for Truthy.

Checks that the last element is less than or equal to its parent at index len(l)/2-1. Then, recurses to check that the same is True with the last element of the list removed, and so on until the list is empty.


48 bytes:

f=lambda l,i=1:l==l[:i]or l[~-i/2]/l[i]*f(l,i+1)

Checks that at each index i, the element is at most its parent at index (i-1)/2. The floor-division produces 0 if this is not the case.

Doing the base case as i/len(l)or gives the same length. I had tried zipping at first, but got longer code (57 bytes).

lambda l:all(map(lambda a,b,c:b<=a>=c,l,l[1::2],l[2::2]))

Python 2, 45 bytes

f=lambda l:l==[]or l[len(l)/2-1]/l.pop()*f(l)

Outputs 0 for Falsy, nonzero for Truthy.

Checks that the last element is less than or equal to its parent at index len(l)/2-1. Then, recurses to check that the same is True with the last element of the list removed, and so on until the list is empty.


48 bytes:

f=lambda l,i=1:l==l[:i]or l[~-i/2]/l[i]*f(l,i+1)

Checks that at each index i, the element is at most its parent at index (i-1)/2. The floor-division produces 0 if this is not the case.

Doing the base case as i/len(l)or gives the same length. I had tried zipping at first, but got longer code (57 bytes).

lambda l:all(map(lambda a,b,c:b<=a>=c,l,l[1::2],l[2::2]))
added 293 characters in body
Source Link
xnor
  • 146.6k
  • 26
  • 279
  • 652

##Python 2, 4845 bytes

f=lambda l,i=1:l==l[:i]orl==[]or l[~-il[len(l)/2]2-1]/l[i]*fl.pop()*f(l,i+1)

Outputs 0 for Falsy, nonzero for Truthy.

Checks that the last element is less than or equal to its parent at index len(l)/2-1. Then, recurses to check that the same is True with the last element of the list removed, and so on until the list is empty.


48 bytes:

f=lambda l,i=1:l==l[:i]or l[~-i/2]/l[i]*f(l,i+1)

Checks that at each index i, the element is at most its parent at index (i-1)/2. The floor-division produces 0 if this is not the case.

Doing the base case as i/len(l)or gives the same length. I had tried zipping at first, but got longer code (57 bytes).

lambda l:all(map(lambda a,b,c:b<=a>=c,l,l[1::2],l[2::2]))

##Python 2, 48 bytes

f=lambda l,i=1:l==l[:i]or l[~-i/2]/l[i]*f(l,i+1)

Outputs 0 for Falsy, nonzero for Truthy.

Checks that at each index i, the element is at most its parent at index (i-1)/2. The floor-division produces 0 if this is not the case.

Doing the base case as i/len(l)or gives the same length. I had tried zipping at first, but got longer code (57 bytes).

lambda l:all(map(lambda a,b,c:b<=a>=c,l,l[1::2],l[2::2]))

##Python 2, 45 bytes

f=lambda l:l==[]or l[len(l)/2-1]/l.pop()*f(l)

Outputs 0 for Falsy, nonzero for Truthy.

Checks that the last element is less than or equal to its parent at index len(l)/2-1. Then, recurses to check that the same is True with the last element of the list removed, and so on until the list is empty.


48 bytes:

f=lambda l,i=1:l==l[:i]or l[~-i/2]/l[i]*f(l,i+1)

Checks that at each index i, the element is at most its parent at index (i-1)/2. The floor-division produces 0 if this is not the case.

Doing the base case as i/len(l)or gives the same length. I had tried zipping at first, but got longer code (57 bytes).

lambda l:all(map(lambda a,b,c:b<=a>=c,l,l[1::2],l[2::2]))
Source Link
xnor
  • 146.6k
  • 26
  • 279
  • 652

##Python 2, 48 bytes

f=lambda l,i=1:l==l[:i]or l[~-i/2]/l[i]*f(l,i+1)

Outputs 0 for Falsy, nonzero for Truthy.

Checks that at each index i, the element is at most its parent at index (i-1)/2. The floor-division produces 0 if this is not the case.

Doing the base case as i/len(l)or gives the same length. I had tried zipping at first, but got longer code (57 bytes).

lambda l:all(map(lambda a,b,c:b<=a>=c,l,l[1::2],l[2::2]))