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

Incorrect TIO-links apparently.. :/
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394

05AB1E, 13 (or 7?) bytes

εNUεIŸsåiXN‚?

First input is the matrix; second the range as pair of integers.
Outputs pairs of 0-based indices without delimiter to STDOUT.

Try it online or verify all test cases.

Not sure if this is a valid output-format:

ŸIåεƶ0K

First input is the range as pair of integers; second the matrix.
Outputs the 1-based truthy indices of each row.

Try it online Try it online or verify all test cases verify all test cases.

Explanation:

ε # Map over each row of the (implicit) first input-matrix:
 NU # Store the row-index in variable `X`
 ε # Map over each integer in the row:
 I # Push the second (implicit) input-pair
 Ÿ # Convert it to an inclusive ranged list
 såi # If the current integer is in this list:
 XN‚ # Pair `X` with the inner map-index
 ? # Pop and output it
Ÿ # Convert the (implicit) first input-pair to an inclusive ranged list
 I # Push the second input-matrix
 å # Check for each inner-most value if it's within this range
 ε # Map over these integers:
 ƶ # Multiply each value by its 1-based index
 0K # Remove all 0s
 # (after which the list of lists is output implicitly)

05AB1E, 13 (or 7?) bytes

εNUεIŸsåiXN‚?

First input is the matrix; second the range as pair of integers.
Outputs pairs of 0-based indices without delimiter to STDOUT.

Try it online or verify all test cases.

Not sure if this is a valid output-format:

ŸIåεƶ0K

First input is the range as pair of integers; second the matrix.
Outputs the 1-based truthy indices of each row.

Try it online or verify all test cases.

Explanation:

ε # Map over each row of the (implicit) first input-matrix:
 NU # Store the row-index in variable `X`
 ε # Map over each integer in the row:
 I # Push the second (implicit) input-pair
 Ÿ # Convert it to an inclusive ranged list
 såi # If the current integer is in this list:
 XN‚ # Pair `X` with the inner map-index
 ? # Pop and output it
Ÿ # Convert the (implicit) first input-pair to an inclusive ranged list
 I # Push the second input-matrix
 å # Check for each inner-most value if it's within this range
 ε # Map over these integers:
 ƶ # Multiply each value by its 1-based index
 0K # Remove all 0s
 # (after which the list of lists is output implicitly)

05AB1E, 13 (or 7?) bytes

εNUεIŸsåiXN‚?

First input is the matrix; second the range as pair of integers.
Outputs pairs of 0-based indices without delimiter to STDOUT.

Try it online or verify all test cases.

Not sure if this is a valid output-format:

ŸIåεƶ0K

First input is the range as pair of integers; second the matrix.
Outputs the 1-based truthy indices of each row.

Try it online or verify all test cases.

Explanation:

ε # Map over each row of the (implicit) first input-matrix:
 NU # Store the row-index in variable `X`
 ε # Map over each integer in the row:
 I # Push the second (implicit) input-pair
 Ÿ # Convert it to an inclusive ranged list
 såi # If the current integer is in this list:
 XN‚ # Pair `X` with the inner map-index
 ? # Pop and output it
Ÿ # Convert the (implicit) first input-pair to an inclusive ranged list
 I # Push the second input-matrix
 å # Check for each inner-most value if it's within this range
 ε # Map over these integers:
 ƶ # Multiply each value by its 1-based index
 0K # Remove all 0s
 # (after which the list of lists is output implicitly)
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394

05AB1E, 13 (or 7?) bytes

εNUεIŸsåiXN‚?

First input is the matrix; second the range as pair of integers.
Outputs pairs of 0-based indices without delimiter to STDOUT.

Try it online or verify all test cases.

Not sure if this is a valid output-format:

ŸIåεƶ0K

First input is the range as pair of integers; second the matrix.
Outputs the 1-based truthy indices of each row.

Try it online or verify all test cases.

Explanation:

ε # Map over each row of the (implicit) first input-matrix:
 NU # Store the row-index in variable `X`
 ε # Map over each integer in the row:
 I # Push the second (implicit) input-pair
 Ÿ # Convert it to an inclusive ranged list
 såi # If the current integer is in this list:
 XN‚ # Pair `X` with the inner map-index
 ? # Pop and output it
Ÿ # Convert the (implicit) first input-pair to an inclusive ranged list
 I # Push the second input-matrix
 å # Check for each inner-most value if it's within this range
 ε # Map over these integers:
 ƶ # Multiply each value by its 1-based index
 0K # Remove all 0s
 # (after which the list of lists is output implicitly)

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