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

added 42 characters in body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

Jelly, (削除) 12 (削除ここまで) 11 bytes

ŒJ%þ`ṪỊ§TịF

A monadic Link that accepts a rectangular multi-dimensional list and yields the elements that are on its "surface".

Try it online!

How?

Updating...

ŒJ=þ`.ịS§TịFŒJ%þ`ṪỊ§TịF - Link: rectangular multi-dimensional list, M
ŒJ - multi-dimensional indices of M -> [[1,1,1,...],...,[height,width,depth,...]]
 ` - use as both arguments of:
 þ - make a table of:
 = % - equals?modulo (vectorises)
 . - literal 0.5
  - (0.5) index into (our table)tail -> [last row of table[...[x%height, first row of table]y%width,z%depth,...]...]
 S - sumabs(x)<=1? (column-wisevectorises)
 § - sums (of those)
 T - truthy indices (of that)
 F - flatten (M) (N.B. same order as the indices produced by ŒJ)
 ị - index-into

Jelly, (削除) 12 (削除ここまで) 11 bytes

ŒJ%þ`ṪỊ§TịF

A monadic Link that accepts a rectangular multi-dimensional list and yields the elements that are on its "surface".

Try it online!

How?

Updating...

ŒJ=þ`.ịS§TịF - Link: rectangular multi-dimensional list, M
ŒJ - multi-dimensional indices of M -> [[1,1,1,...],...,[height,width,depth,...]]
 ` - use as both arguments of:
 þ - make a table of:
 = - equals? (vectorises)
 . - literal 0.5
  - (0.5) index into (our table) -> [last row of table, first row of table]
 S - sum (column-wise)
 § - sums (of those)
 T - truthy indices (of that)
 F - flatten (M) (N.B. same order as the indices produced by ŒJ)
 ị - index-into

Jelly, (削除) 12 (削除ここまで) 11 bytes

ŒJ%þ`ṪỊ§TịF

A monadic Link that accepts a rectangular multi-dimensional list and yields the elements that are on its "surface".

Try it online!

How?

ŒJ%þ`ṪỊ§TịF - Link: rectangular multi-dimensional list, M
ŒJ - multi-dimensional indices of M -> [[1,1,1,...],...,[height,width,depth,...]]
 ` - use as both arguments of:
 þ - make a table of:
 % - modulo (vectorises)
  - tail -> [...[x%height,y%width,z%depth,...]...]
  - abs(x)<=1? (vectorises)
 § - sums (of those)
 T - truthy indices (of that)
 F - flatten (M) (N.B. same order as the indices produced by ŒJ)
 ị - index-into
added 42 characters in body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

Jelly, 12 (削除) 12 (削除ここまで) 11 bytes

ŒJ=þ`.ịS§TịFŒJ%þ`ṪỊ§TịF

A monadic Link that accepts a rectangular multi-dimensional list and yields the elements that are on its "surface".

Try it online! Try it online!

How?

Updating...

ŒJ=þ`.ịS§TịF - Link: rectangular multi-dimensional list, M
ŒJ - multi-dimensional indices of M -> [[1,1,1,...],...,[height,width,depth,...]]
 ` - use as both arguments of:
 þ - make a table of:
 = - equals? (vectorises)
 . - literal 0.5
 ị - (0.5) index into (our table) -> [last row of table, first row of table]
 S - sum (column-wise)
 § - sums (of those)
 T - truthy indices (of that)
 F - flatten (M) (N.B. same order as the indices produced by ŒJ)
 ị - index-into

Jelly, 12 bytes

ŒJ=þ`.ịS§TịF

A monadic Link that accepts a rectangular multi-dimensional list and yields the elements that are on its "surface".

Try it online!

How?

ŒJ=þ`.ịS§TịF - Link: rectangular multi-dimensional list, M
ŒJ - multi-dimensional indices of M -> [[1,1,1,...],...,[height,width,depth,...]]
 ` - use as both arguments of:
 þ - make a table of:
 = - equals? (vectorises)
 . - literal 0.5
 ị - (0.5) index into (our table) -> [last row of table, first row of table]
 S - sum (column-wise)
 § - sums (of those)
 T - truthy indices (of that)
 F - flatten (M) (N.B. same order as the indices produced by ŒJ)
 ị - index-into

Jelly, (削除) 12 (削除ここまで) 11 bytes

ŒJ%þ`ṪỊ§TịF

A monadic Link that accepts a rectangular multi-dimensional list and yields the elements that are on its "surface".

Try it online!

How?

Updating...

ŒJ=þ`.ịS§TịF - Link: rectangular multi-dimensional list, M
ŒJ - multi-dimensional indices of M -> [[1,1,1,...],...,[height,width,depth,...]]
 ` - use as both arguments of:
 þ - make a table of:
 = - equals? (vectorises)
 . - literal 0.5
 ị - (0.5) index into (our table) -> [last row of table, first row of table]
 S - sum (column-wise)
 § - sums (of those)
 T - truthy indices (of that)
 F - flatten (M) (N.B. same order as the indices produced by ŒJ)
 ị - index-into
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

Jelly, 12 bytes

ŒJ=þ`.ịS§TịF

A monadic Link that accepts a rectangular multi-dimensional list and yields the elements that are on its "surface".

Try it online!

How?

ŒJ=þ`.ịS§TịF - Link: rectangular multi-dimensional list, M
ŒJ - multi-dimensional indices of M -> [[1,1,1,...],...,[height,width,depth,...]]
 ` - use as both arguments of:
 þ - make a table of:
 = - equals? (vectorises)
 . - literal 0.5
 ị - (0.5) index into (our table) -> [last row of table, first row of table]
 S - sum (column-wise)
 § - sums (of those)
 T - truthy indices (of that)
 F - flatten (M) (N.B. same order as the indices produced by ŒJ)
 ị - index-into

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