Skip to main content
Commonmark migration
Source Link

#MATL, 13 12 bytes

MATL, 13 12 bytes

ttf2/k)>~4L)

Try it online! Or verify all test cases.

An array is truthy if it is non-empty and all its entries are nonzero. Otherwise it's falsy. Here are some examples.

###Explanation

Explanation

t     % Take input implicitly. Duplicate
tf    % Duplicate and push indices of nonzero entries. This gives [1 2 ... n] where n
      % is input size
2/k   % Divide by 2 and round down
)     % Index into input. Gives array of parents, except for the first entry
>~    % True for entries of the input that don't exceed those in the array of parents
4L)   % Discard first entry

#MATL, 13 12 bytes

ttf2/k)>~4L)

Try it online! Or verify all test cases.

An array is truthy if it is non-empty and all its entries are nonzero. Otherwise it's falsy. Here are some examples.

###Explanation

t     % Take input implicitly. Duplicate
tf    % Duplicate and push indices of nonzero entries. This gives [1 2 ... n] where n
      % is input size
2/k   % Divide by 2 and round down
)     % Index into input. Gives array of parents, except for the first entry
>~    % True for entries of the input that don't exceed those in the array of parents
4L)   % Discard first entry

MATL, 13 12 bytes

ttf2/k)>~4L)

Try it online! Or verify all test cases.

An array is truthy if it is non-empty and all its entries are nonzero. Otherwise it's falsy. Here are some examples.

Explanation

t     % Take input implicitly. Duplicate
tf    % Duplicate and push indices of nonzero entries. This gives [1 2 ... n] where n
      % is input size
2/k   % Divide by 2 and round down
)     % Index into input. Gives array of parents, except for the first entry
>~    % True for entries of the input that don't exceed those in the array of parents
4L)   % Discard first entry
deleted 184 characters in body
Source Link
Luis Mendo
  • 105.3k
  • 9
  • 135
  • 372

#MATL, 1313 12 bytes

ttn:2ttf2/k)>~4L)

Try it online!Try it online! Or verify all test cases at onceverify all test cases.

An array is truthy if it is non-empty and all its entries are nonzero. Otherwise it's falsy. Here are some examples.

###Explanation

t     % Take input implicitly. Duplicate
tn:tf    % Duplicate and generatepush rangeindices of nonzero entries. This gives [1 2 ... n] where n
      % is input size
2/k   % Divide by 2 and round down
)     % Index into input. Gives array of parents, except for the first entry
>~    % True for entries of the input that don't exceed those in the array of parents
4L)   % Discard first entry

#MATL, 13 bytes

ttn:2/k)>~4L)

Try it online! Or verify all test cases at once.

An array is truthy if it is non-empty and all its entries are nonzero. Otherwise it's falsy. Here are some examples.

###Explanation

t     % Take input implicitly. Duplicate
tn:   % Duplicate and generate range [1 2 ...n] where n is input size
2/k   % Divide by 2 and round down
)     % Index into input. Gives array of parents, except for the first entry
>~    % True for entries of the input that don't exceed those in the array of parents
4L)   % Discard first entry

#MATL, 13 12 bytes

ttf2/k)>~4L)

Try it online! Or verify all test cases.

An array is truthy if it is non-empty and all its entries are nonzero. Otherwise it's falsy. Here are some examples.

###Explanation

t     % Take input implicitly. Duplicate
tf    % Duplicate and push indices of nonzero entries. This gives [1 2 ... n] where n
      % is input size
2/k   % Divide by 2 and round down
)     % Index into input. Gives array of parents, except for the first entry
>~    % True for entries of the input that don't exceed those in the array of parents
4L)   % Discard first entry
deleted 1 character in body
Source Link
Luis Mendo
  • 105.3k
  • 9
  • 135
  • 372

#MATL, 13 bytes

ttn:2/k)>~4L)

Try it online! Or verify all test cases at once.

An array is truthy if it is non-empty and all its entries are nonzero, or is. Otherwise it's falsy otherwise. Here are some examples.

###Explanation

t     % Take input implicitly. Duplicate
tn:   % Duplicate and generate range [1 2 ...n] where n is input size
2/k   % Divide by 2 and round down
)     % Index into input. Gives array of parents, except for the first entry
>~    % True for entries of the input that don't exceed those in the array of parents
4L)   % Discard first entry

#MATL, 13 bytes

ttn:2/k)>~4L)

Try it online! Or verify all test cases at once.

An array is truthy if it is non-empty and all its entries are nonzero, or is falsy otherwise. Here are some examples.

###Explanation

t     % Take input implicitly. Duplicate
tn:   % Duplicate and generate range [1 2 ...n] where n is input size
2/k   % Divide by 2 and round down
)     % Index into input. Gives array of parents, except for the first entry
>~    % True for entries of the input that don't exceed those in the array of parents
4L)   % Discard first entry

#MATL, 13 bytes

ttn:2/k)>~4L)

Try it online! Or verify all test cases at once.

An array is truthy if it is non-empty and all its entries are nonzero. Otherwise it's falsy. Here are some examples.

###Explanation

t     % Take input implicitly. Duplicate
tn:   % Duplicate and generate range [1 2 ...n] where n is input size
2/k   % Divide by 2 and round down
)     % Index into input. Gives array of parents, except for the first entry
>~    % True for entries of the input that don't exceed those in the array of parents
4L)   % Discard first entry
added 11 characters in body
Source Link
Luis Mendo
  • 105.3k
  • 9
  • 135
  • 372
Loading
added 376 characters in body
Source Link
Luis Mendo
  • 105.3k
  • 9
  • 135
  • 372
Loading
Source Link
Luis Mendo
  • 105.3k
  • 9
  • 135
  • 372
Loading