Skip to main content
Commonmark migration
Source Link

MATL, 13 bytes

ctgF6Lt&()32>

Input is an array of strings, in the format {'abc' 'de'}.

Output is an array containing only ones, which is truthy, or an array containing at least a zero, which is falsey.

Try it online! Or verify all test cases, including truthiness/falsihood test.

###Explanation

Explanation

c       % Implicit input. Convert to char. This concatenates the
        % strings of the input cell array as rows of a rectangular
        % char array, right-padding with spaces as needed
tg      % Duplicate, convert to logical. Gives a logical array with
        % the same size containing true in all its entries
F       % Push false
6L      % Push the array [2, j-1], where j is the imaginary unit.
        % When used as an index, this is interpreted as 2:end-1
t       % Duplicate
&(      % Assignment indexing with 4 inputs: original array, new
        % value, two indexing arrays. This writes false at the inner
        % rectangle (2:end-1)×(2:end-1) of the logical array that
        % initially only contained true. This will be used as a
        % logical index (mask) into the rectangular char array
)       % Reference indexing. This selects the border of the char
        % array. The result is a column vector of chars
32>     % Is each entry greater than 32? (ASCII code for space)
        % Implicit display

MATL, 13 bytes

ctgF6Lt&()32>

Input is an array of strings, in the format {'abc' 'de'}.

Output is an array containing only ones, which is truthy, or an array containing at least a zero, which is falsey.

Try it online! Or verify all test cases, including truthiness/falsihood test.

###Explanation

c       % Implicit input. Convert to char. This concatenates the
        % strings of the input cell array as rows of a rectangular
        % char array, right-padding with spaces as needed
tg      % Duplicate, convert to logical. Gives a logical array with
        % the same size containing true in all its entries
F       % Push false
6L      % Push the array [2, j-1], where j is the imaginary unit.
        % When used as an index, this is interpreted as 2:end-1
t       % Duplicate
&(      % Assignment indexing with 4 inputs: original array, new
        % value, two indexing arrays. This writes false at the inner
        % rectangle (2:end-1)×(2:end-1) of the logical array that
        % initially only contained true. This will be used as a
        % logical index (mask) into the rectangular char array
)       % Reference indexing. This selects the border of the char
        % array. The result is a column vector of chars
32>     % Is each entry greater than 32? (ASCII code for space)
        % Implicit display

MATL, 13 bytes

ctgF6Lt&()32>

Input is an array of strings, in the format {'abc' 'de'}.

Output is an array containing only ones, which is truthy, or an array containing at least a zero, which is falsey.

Try it online! Or verify all test cases, including truthiness/falsihood test.

Explanation

c       % Implicit input. Convert to char. This concatenates the
        % strings of the input cell array as rows of a rectangular
        % char array, right-padding with spaces as needed
tg      % Duplicate, convert to logical. Gives a logical array with
        % the same size containing true in all its entries
F       % Push false
6L      % Push the array [2, j-1], where j is the imaginary unit.
        % When used as an index, this is interpreted as 2:end-1
t       % Duplicate
&(      % Assignment indexing with 4 inputs: original array, new
        % value, two indexing arrays. This writes false at the inner
        % rectangle (2:end-1)×(2:end-1) of the logical array that
        % initially only contained true. This will be used as a
        % logical index (mask) into the rectangular char array
)       % Reference indexing. This selects the border of the char
        % array. The result is a column vector of chars
32>     % Is each entry greater than 32? (ASCII code for space)
        % Implicit display
added 1102 characters in body
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382

MATL, 13 bytes

ctgF6Lt&()32>

Input is an array of strings, in the format {'abc' 'de'}.

Output is an array containing only ones, which is truthy, or an array containing at least a zero, which is falsey.

Try it online! Or verify all test cases, including truthiness/falsihood test.

###Explanation

c       % Implicit input. Convert to char. This concatenates the
        % strings of the input cell array as rows of a rectangular
        % char array, right-padding with spaces as needed
tg      % Duplicate, convert to logical. Gives a logical array with
        % the same size containing true in all its entries
F       % Push false
6L      % Push the array [2, j-1], where j is the imaginary unit.
        % When used as an index, this is interpreted as 2:end-1
t       % Duplicate
&(      % Assignment indexing with 4 inputs: original array, new
        % value, two indexing arrays. This writes false at the inner
        % rectangle (2:end-1)×(2:end-1) of the logical array that
        % initially only contained true. This will be used as a
        % logical index (mask) into the rectangular char array
)       % Reference indexing. This selects the border of the char
        % array. The result is a column vector of chars
32>     % Is each entry greater than 32? (ASCII code for space)
        % Implicit display

MATL, 13 bytes

ctgF6Lt&()32>

Input is an array of strings, in the format {'abc' 'de'}.

Output is an array containing only ones, which is truthy, or an array containing at least a zero, which is falsey.

Try it online! Or verify all test cases, including truthiness/falsihood test.

MATL, 13 bytes

ctgF6Lt&()32>

Input is an array of strings, in the format {'abc' 'de'}.

Output is an array containing only ones, which is truthy, or an array containing at least a zero, which is falsey.

Try it online! Or verify all test cases, including truthiness/falsihood test.

###Explanation

c       % Implicit input. Convert to char. This concatenates the
        % strings of the input cell array as rows of a rectangular
        % char array, right-padding with spaces as needed
tg      % Duplicate, convert to logical. Gives a logical array with
        % the same size containing true in all its entries
F       % Push false
6L      % Push the array [2, j-1], where j is the imaginary unit.
        % When used as an index, this is interpreted as 2:end-1
t       % Duplicate
&(      % Assignment indexing with 4 inputs: original array, new
        % value, two indexing arrays. This writes false at the inner
        % rectangle (2:end-1)×(2:end-1) of the logical array that
        % initially only contained true. This will be used as a
        % logical index (mask) into the rectangular char array
)       % Reference indexing. This selects the border of the char
        % array. The result is a column vector of chars
32>     % Is each entry greater than 32? (ASCII code for space)
        % Implicit display
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382

MATL, 13 bytes

ctgF6Lt&()32>

Input is an array of strings, in the format {'abc' 'de'}.

Output is an array containing only ones, which is truthy, or an array containing at least a zero, which is falsey.

Try it online! Or verify all test cases, including truthiness/falsihood test.