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

replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

Slip, 28 bytes

27 bytes of code, +1 for p option.

(?|1011)(\(?|1110)){2}1111円

Requires input as a multiline rectangle of 1's and 0's without spaces. Try it here (with third testcase as input).

Explanation

Slip is a language from the 2-D Pattern Matching 2-D Pattern Matching challenge. Sp3000 could say a lot more about it than I can, but basically it's an extended form of regex with some directional commands that let you match in two dimensions. The above code uses the eponymous "slip" command \, which doesn't change the match pointer's direction but moves it sideways by one character. It also uses "stationary group" (?|...), which matches something and then resets the pointer to its previous location.

The code breaks down as follows:

(?|1011) Match 1011; reset pointer to beginning of match
 ( ){2} Do the following twice:
 \ Slip (moves pointer down one row)
 (?|1110) Match 1110; reset pointer to beginning of match
 1111円 Slip and match 1111

This matches the 0xBEEF square. The p option outputs the coordinates of the match, 0-indexed.

Slip, 28 bytes

27 bytes of code, +1 for p option.

(?|1011)(\(?|1110)){2}1111円

Requires input as a multiline rectangle of 1's and 0's without spaces. Try it here (with third testcase as input).

Explanation

Slip is a language from the 2-D Pattern Matching challenge. Sp3000 could say a lot more about it than I can, but basically it's an extended form of regex with some directional commands that let you match in two dimensions. The above code uses the eponymous "slip" command \, which doesn't change the match pointer's direction but moves it sideways by one character. It also uses "stationary group" (?|...), which matches something and then resets the pointer to its previous location.

The code breaks down as follows:

(?|1011) Match 1011; reset pointer to beginning of match
 ( ){2} Do the following twice:
 \ Slip (moves pointer down one row)
 (?|1110) Match 1110; reset pointer to beginning of match
 1111円 Slip and match 1111

This matches the 0xBEEF square. The p option outputs the coordinates of the match, 0-indexed.

Slip, 28 bytes

27 bytes of code, +1 for p option.

(?|1011)(\(?|1110)){2}1111円

Requires input as a multiline rectangle of 1's and 0's without spaces. Try it here (with third testcase as input).

Explanation

Slip is a language from the 2-D Pattern Matching challenge. Sp3000 could say a lot more about it than I can, but basically it's an extended form of regex with some directional commands that let you match in two dimensions. The above code uses the eponymous "slip" command \, which doesn't change the match pointer's direction but moves it sideways by one character. It also uses "stationary group" (?|...), which matches something and then resets the pointer to its previous location.

The code breaks down as follows:

(?|1011) Match 1011; reset pointer to beginning of match
 ( ){2} Do the following twice:
 \ Slip (moves pointer down one row)
 (?|1110) Match 1110; reset pointer to beginning of match
 1111円 Slip and match 1111

This matches the 0xBEEF square. The p option outputs the coordinates of the match, 0-indexed.

Source Link
DLosc
  • 40.7k
  • 6
  • 87
  • 142

Slip, 28 bytes

27 bytes of code, +1 for p option.

(?|1011)(\(?|1110)){2}1111円

Requires input as a multiline rectangle of 1's and 0's without spaces. Try it here (with third testcase as input).

Explanation

Slip is a language from the 2-D Pattern Matching challenge. Sp3000 could say a lot more about it than I can, but basically it's an extended form of regex with some directional commands that let you match in two dimensions. The above code uses the eponymous "slip" command \, which doesn't change the match pointer's direction but moves it sideways by one character. It also uses "stationary group" (?|...), which matches something and then resets the pointer to its previous location.

The code breaks down as follows:

(?|1011) Match 1011; reset pointer to beginning of match
 ( ){2} Do the following twice:
 \ Slip (moves pointer down one row)
 (?|1110) Match 1110; reset pointer to beginning of match
 1111円 Slip and match 1111

This matches the 0xBEEF square. The p option outputs the coordinates of the match, 0-indexed.

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