Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This challenge was inspired by this Wendy's commercial from 1984.

Where's the beef?

Illustration by T S Rogers -- Source: http://teaessare.com/wheres-the-beef/

Your task is to find a hexadecimal 0xBEEF on a binary bun.

The 'beef' consists of the following pattern:

1 0 1 1  (0xB)
1 1 1 0  (0xE)
1 1 1 0  (0xE)
1 1 1 1  (0xF)

And the 'bun' consists of a 12x12 binary matrix, such as:

1 1 1 0 0 1 1 1 1 1 1 0
1 1 0 1 0 0 1 0 0 0 0 0
0 1 0 0 0 1 1 1 1 1 0 1
1 0 0 1 0 0 1 0 0 1 0 0
1 0 0 1 0 1 1 0 0 1 1 1
1 1 1 1 1 1 0 0 0 0 1 0
1 1 0 1 1 1 0 0 0 0 0 1
1 0 0 1 1 1 1 0 0 0 0 1
1 0 0 1 1 1 0 1 1 1 1 1
1 1 1 1 1 0 0 1 1 1 1 1
1 0 0 0 0 1 0 1 0 1 1 1
1 1 0 0 1 1 0 0 0 0 1 1

Input

Your program or function will take the binary matrix as input. The matrix format is very flexible, but it must be clearly described in your answer.

For instance:

  • a single binary string, with or without separators between the rows:

    "111001111110 110100100000..."

    or:

    "111001111110110100100000..."

  • an array of binary strings:

    ["111001111110", "110100100000", ...]

  • an array of numbers (each number describing a row once converted back to binary and left-padded with zeros):

    [3710, 3360, ...]

Output

The coordinates (X, Y) of the 'beef', (0, 0) being the top left corner of the bun.

Alternatively, you may use 1-based coordinates (but not a mix of both formats, like 0-based for X and 1-based for Y).

For the above example, the expected answer is (3, 4) (0-based) or (4, 5) (1-based):

   00 01 02 03 04 05 06 07 08 09 10 11 
00  1  1  1  0  0  1  1  1  1  1  1  0
01  1  1  0  1  0  0  1  0  0  0  0  0
02  0  1  0  0  0  1  1  1  1  1  0  1
03  1  0  0  1  0  0  1  0  0  1  0  0
04  1  0  0 [1  0  1  1] 0  0  1  1  1
05  1  1  1 [1  1  1  0] 0  0  0  1  0
06  1  1  0 [1  1  1  0] 0  0  0  0  1
07  1  0  0 [1  1  1  1] 0  0  0  0  1
08  1  0  0  1  1  1  0  1  1  1  1  1
09  1  1  1  1  1  0  0  1  1  1  1  1
10  1  0  0  0  0  1  0  1  0  1  1  1
11  1  1  0  0  1  1  0  0  0  0  1  1

Again, any reasonable format would work as long as it is specified in your answer. Please also mention if you're using 0-based or 1-based coordinates.

Rules

  • You can safely assume that there is always exactly one 'beef' on the bun. Your code is not required to support cases with more than one beef or no beef at all.
  • The beef pattern will always appear as described. It will never be rotated or mirrored in any way.
  • This is code-golf, so the shortest answer in bytes wins. Standard loopholes are forbidden.

Test cases

In the following test cases, each row of the matrix is expressed as its decimal representation.

Input : [ 3710, 3360, 1149, 2340, 2407, 4034, 3521, 2529, 2527, 3999, 2135, 3267 ]
Output: [ 3, 4 ]

Input : [ 1222, 3107, 1508, 3997, 1906, 379, 2874, 2926, 1480, 1487, 3565, 633 ]
Output: [ 3, 7 ]

Input : [ 2796, 206, 148, 763, 429, 1274, 2170, 2495, 42, 1646, 363, 1145 ]
Output: [ 6, 4 ]

Input : [ 3486, 3502, 1882, 1886, 2003, 1442, 2383, 2808, 1416, 1923, 2613, 519 ]
Output: [ 1, 1 ]

Input : [ 3661, 2382, 2208, 1583, 1865, 3969, 2864, 3074, 475, 2382, 1838, 127 ]
Output: [ 8, 8 ]

Input : [ 361, 1275, 3304, 2878, 3733, 3833, 3971, 3405, 2886, 448, 3101, 22 ]
Output: [ 0, 3 ]

Input : [ 3674, 2852, 1571, 3582, 1402, 3331, 1741, 2678, 2076, 2685, 734, 261 ]
Output: [ 7, 7 ]
share|improve this question
    
Is using 1-based indices allowed (where the top left is (1,1))? – Doorknob yesterday
    
@Doorknob Yes, if it's the same format for both X and Y (question updated accordingly). – Arnauld yesterday
23  
Bonus points if we also output wether the 0xBEEF is 0xDEAD? :P – TùxCräftîñg yesterday
5  
This challenge is really random and kinda silly. But it's actually a pretty great challenge still. +1 – DJMcMayhem yesterday
    
Can I output y, x (i.e. reverse order)? – Luis Mendo yesterday

19 Answers 19

vim, 126 80 77 76

/\v1011\_.{9}(1110\_.{9}){2}1111<cr>:exe'norm Go'.join(getpos('.'))<cr>xxdawhPXXd{

Expects input in the form

111001111110
110100100000
010001111101
100100100100
100101100111
111111000010
110111000001
100111100001
100111011111
111110011111
100001010111
110011000011

And outputs (with 1-based indices) as

4 5
/                      regex search for...
\v                     enable "very magic" mode (less escaping)
1011\_.{9}             find the first line ("B"), followed by 8 chars + 1 \n
(1110\_.{9}){2}        find the second and third lines ("EE")
1111<cr>               find the fourth line ("F")
:exe'norm Go'.         insert at the beginning of the file...
join(getpos('.'))<cr>  the current position of the cursor
xxdawhPXX              do some finagling to put the numbers in the right order
d{                     delete the input

Thanks to Jörg Hülsermann for indirectly saving 46 bytes by making me realize my regex was super dumb, and to DJMcMayhem for 3 more bytes.

share|improve this answer
1  
A couple tips: 1) Yp is better than yyp (even though I know you object to Y :P) 2) the whitespace in exec 'norm Go' is unnecessary. And 3) kd{ is shorter than kdgg. (Haven't tested that though) – DJMcMayhem yesterday
1  
@DJMcMayhem Oh, I always forget about Y because I have it rebound in my vimrc. :P In fact, the kdgg was equivalent to just d{, which, surprisingly, does not delete the current line. – Doorknob yesterday
    
Oh interesting. How convenient! – DJMcMayhem yesterday
    
I'm always confused when things such as { turn out to be a character movement; so I have do something like {d'' instead to delete whole lines. – Neil yesterday
    
@Neil You could do dV{ instead – DJMcMayhem yesterday

JavaScript (ES6), 63 60 56 bytes

s=>[(i=s.search(/1011.{8}(1110.{8}){2}1111/s))%12,i/12|0]

Takes input as a 144-character binary string, returns zero-indexed values. Edit: Saved 3 bytes thanks to @JörgHülsermann. Saved 4 bytes thanks to @ETHproductions.

share|improve this answer
    
Could you possibly use s.search(r) instead of r.exec(s).index? – ETHproductions yesterday
    
@ETHproductions Of course I could. I must have been half asleep yesterday... – Neil yesterday

Jelly, 20 17 16 bytes

ṡ€4ḄZw€“¿ÇÇБĖUṀ

Input is in form of a Boolean matrix, output is the 1-based index pair (Y, X).

Try it online! or verify all test cases.

How it works

ṡ€4ḄZw€“¿ÇÇБĖUṀ  Main link. Argument: M (2D array of Booleans)

ṡ€4               Split each row into 9 chunks of length 4.
   Ḅ              Convert these chunks from base 2 to integer.
    Z             Zip/transpose. This places the columns of generated integers
                  into the rows of the matrix to comb through them.
       “¿ÇÇБ     Push the array of code points (in Jelly's code page) of these
                  characters, i.e., 0xB, 0xE, 0xE, and 0xF.
     w€           Window-index each; in each row, find the index of the contiguous
                  subarray [0xB, 0xE, 0xE, 0xF] (0 if not found).
                  Since the matrix contains on one BEEF, this will yield an array
                  of zeroes, with a single non-zero Y at index X.
             Ė    Enumerate; prefix each integer with its index.
              U   Upend; reverse the pairs to brings the zeroes to the beginning.
               Ṁ  Take the maximum. This yields the only element with positive
                  first coordinate, i.e., the pair [Y, X].
share|improve this answer
8  
I don't get it... how can you code something that is not human readable?? – L3n yesterday
6  
Jelly is by far easier to write than to read. :P – Dennis yesterday
26  
@l3n you seem to imply that Dennis is a human. While it is a possibility, given the kind of tricks that routinely pulls out, I wouldn't discount other ... let's say, more cyberpunk alternatives ;-) – Francesco yesterday
1  
You could output (x,y) with ṡ4Z€Ḅw€“Ье‘ĖUṀ – Jonathan Allan yesterday
1  
@JonathanAllan Nice. There's also ṡ€4ḄZjw“¿ÇÇБ’d24 with 0-based indexing, but it is, unfortunately, one byte longer. – Dennis yesterday

C, 146 177 173 bytes

Thanks to Numberknot for fixing the code (shifting the lower three rows).

Saving 4 bytes by replacing >>=1 with /=2 in 4 places.

#define T(i,n) (A[y+i]&15)==n
int b(int A[12]){int x=9;while(x--){for(int y=0;++y<9;A[y]/=2)if(T(0,11)&&T(1,14)&&T(2,14)&&T(3,15))return(x<<4)+y;A[9]/=2;A[10]/=2;A[11]/=2;}}

Ungolfed:

int b(int A[12]) {
 for (int x=8; x>=0; --x) {
  for (int y=0; y<9; ++y) {
   if ((A[y]&15)==11 && (A[y+1]&15)==14 && (A[y+2]&15)==14 && (A[y+3]&15)==15) { 
    return (x<<4) + y; 
   }
   A[y]/=2;
  }
  A[9]/=2; A[10]/=2; A[11]/=2;
 }
}

Returns x,y (0-based) in the high and low nibble of a byte.

Usage:

int temp=b(array_to_solve);
int x=temp>>4;
int y=temp&15;
printf("%d %d\n",x,y);
share|improve this answer

PHP, 101 Bytes

binaray string as input without separators returns zero-indexed values.

preg_match("#^(.*)1011(.{8}1110){2}.{8}1111#",$argv[1],$c);echo(($s=strlen($c[1]))%12).",".($s/12^0);

array of numbers as input 142 Bytes

<?foreach($_GET[a]as$a)$b.=sprintf("%012b",$a);preg_match("#^(.*)1011(.{8}1110){2}.{8}1111#",$b,$c);echo(($s=strlen($c[1]))%12).",".($s/12^0);
share|improve this answer

Mathematica, 62 bytes

BlockMap[Fold[#+##&,Join@@#]==48879&,#,{4,4},1]~Position~True&

Returns all positions of the BEEF matrix, 1-indexed. The input must be a matrix of binary digits. The x and y in the output are switched, though.

share|improve this answer
    
No worries about x and y being switched. – Arnauld yesterday

MATL, 22 21 bytes

Eq[ODDH]B~EqZ+16=&fhq

Input is a binary matrix, with ; as row separator. Output is 1-based in reverse order: Y X.

Try it online! Or verify all test cases with decimal input format.

Explanation

The pattern is detected using 2D convolution. For this,

  • The matrix and the pattern need to be in bipolar form, that is, 1, -1 instead of 1, 0. Since the pattern has size 4×4, its occurrence is detected by an entry equal to 16 in the convolution output.
  • The convolution kernel needs to be defined as the sought pattern reversed in both dimensions.

Also, since the convolution introduces an offset in the detected indices, this needs to be corrected for in the output.

Eq      % Implicitly input binary matrix. Convert to bipolar form (0 becomes -1)
[ODDH]  % Push array [0 8 8 2]
B       % Convert to binary. Each number gives a row
~Eq     % Negate and convert to bipolar. Gives [1 1 1 1; 0 1 1 1; 0 1 1 1; 1 1 0 1]
        % This is the "BEEF" pattern reversed in the two dimensions. Reversal is
        % needed because a convolution will be used to detect that patter
Z+      % 2D convolution, keeping original size
16=&f   % Find row and column indices of 16 in the above matrix
h       % Concatenate horizontally
q       % Subtract 1. Implicitly display
share|improve this answer

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.

share|improve this answer
    
Nice :) Weirdly, for block patterns sometimes it's golfier to just walk around in a spiral: 1011>001>1(11>){3}1>1 – Sp3000 14 hours ago

Python 2, 98 95 92 bytes

lambda x:'%x'%(`[''.join('%x'%int(s[i:i+4],2)for s in x)for i in range(9)]`.find('beef')+15)

Input is a list of strings, output is the string XY (1-based indices).

Test it on Ideone.

share|improve this answer
    
Might this mistakenly find a "beef" across the boundary where two lines are concatenated? – xnor 13 hours ago
    
Yeah, I think so. I'll roll the edit back until I can test it properly. – Dennis 13 hours ago

Retina, 47 bytes

I'd like to preface this with an apology. I think this is probably terrible and a bad example of how to use the language, but since I used a Regex for my Perl answer, I thought I'd try Retina. I'm not very good. :( The snippets on github helped me greatly though!

Thanks to @wullzx for his comment on my Perl answer for -3 bytes!

Expects input as a binary string and outputs co-ordinates space separated.

(.{12})*(.)*1011(.{8}1110){2}.{8}1111.*
$#2 $#1

Try it online!

Verify all tests at once.

share|improve this answer

Java 7,182 177 bytes

I ported Karl Napf C answer to JAVA And Thanks to Karl Napf for saving 5 bytes by reminding me Bit magic.(Btw i came up with this idea too but @KarlNapf return part idea was yours not mine).Sorry if i displeased you.

(0-based)

int f(int[]a){int x=9,y,z=0;for(;x-->0;){for(y=0;y<9;a[y++]/=2) if((a[y]&15)==11&(a[y+1]&15)==14&(a[y+2]&15)==14&(a[y+3]&15)==15)z=(x<<4)+y;a[y]/=2;a[10]/=2;a[11]/=2;}return z;}

Ungolfed

class Beef {

    public static void main(String[] args) {
        int x = f(new int[] { 1222, 3107, 1508, 3997, 1906, 379, 2874, 2926, 1480, 1487, 3565, 633 });
        System.out.println(x >> 4);
        System.out.println(x & 15);
    }

    static int f(int[] a) {
        int x = 9,
            y,
            z = 0;

        for (; x-- > 0; ) {
            for (y = 0; y < 9; a[y++] /= 2)
                if ((a[y] & 15) == 11 
                  & (a[y + 1] & 15) == 14
                  & (a[y + 2] & 15) == 14 
                  & (a[y + 3] & 15) == 15)
                    z = (x << 4) + y;

            a[y] /= 2;
            a[10] /= 2;
            a[11] /= 2;
        }
        return z;
    }

}
share|improve this answer
2  
What are those four spaces there between a[y++]>>=1) and if((a[y]&15)==. Btw, I count 182 bytes instead of 183? :S – Kevin Cruijssen yesterday
    
@KevinCruijssen fixed . – Numberknot yesterday
1  
Everything alright ;-) – Karl Napf 21 hours ago

Scala, 90 bytes

("1011.{8}(1110.{8}){2}1111".r.findAllMatchIn(_:String).next.start)andThen(i=>(i/12,i%12))

Explanation:

(
  "1011.{8}(1110.{8}){2}1111" //The regex we're using to find the beef
  .r                          //as a regex object
  .findAllMatchIn(_:String)   //find all the matches in the argument thats going to be passed here
  .next                       //get the first one
  .start                      //get its start index
)                             //this is a (String -> Int) function
andThen                       //
(i=>                          //with the found index
  (i/12,i%12)                 //convert it to 2d values
)                             

(a -> b) andThen (b -> c) results in a (a -> c) function, it's like the reverse of compose, but requires fewer type annotations in scala. In this case, it takes a string of the binary digits as input and returns a tuple of zero-based indices.

share|improve this answer

J, 31 29 bytes

[:($#:I.@,)48879=4 4#.@,;._3]

The input is formatted as a 2d array of binary values, and the output is the zero-based coordinates as an array [y, x].

The flattening and base conversion to find the index is something I learned from this comment by Dennis.

Usage

   f =: [:($#:I.@,)48879=4 4#.@,;._3]
   ] m =: _12 ]\ 1 1 1 0 0 1 1 1 1 1 1 0 1 1 0 1 0 0 1 0 0 0 0 0 0 1 0 0 0 1 1 1 1 1 0 1 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 1 1 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 1 0 1 1 0 1 1 1 0 0 0 0 0 1 1 0 0 1 1 1 1 0 0 0 0 1 1 0 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0 0 0 0 1 0 1 0 1 1 1 1 1 0 0 1 1 0 0 0 0 1 1
1 1 1 0 0 1 1 1 1 1 1 0
1 1 0 1 0 0 1 0 0 0 0 0
0 1 0 0 0 1 1 1 1 1 0 1
1 0 0 1 0 0 1 0 0 1 0 0
1 0 0 1 0 1 1 0 0 1 1 1
1 1 1 1 1 1 0 0 0 0 1 0
1 1 0 1 1 1 0 0 0 0 0 1
1 0 0 1 1 1 1 0 0 0 0 1
1 0 0 1 1 1 0 1 1 1 1 1
1 1 1 1 1 0 0 1 1 1 1 1
1 0 0 0 0 1 0 1 0 1 1 1
1 1 0 0 1 1 0 0 0 0 1 1
   f m
4 3
   f (#:~2#~#) 3710 3360 1149 2340 2407 4034 3521 2529 2527 3999 2135 3267
4 3
   f (#:~2#~#) 1222 3107 1508 3997 1906 379 2874 2926 1480 1487 3565 633
7 3
   f (#:~2#~#) 2796 206 148 763 429 1274 2170 2495 42 1646 363 1145
4 6
   f (#:~2#~#) 3486 3502 1882 1886 2003 1442 2383 2808 1416 1923 2613 519
1 1
   f (#:~2#~#) 3661 2382 2208 1583 1865 3969 2864 3074 475 2382 1838 127
8 8
   f (#:~2#~#) 361 1275 3304 2878 3733 3833 3971 3405 2886 448 3101 22
3 0
   f (#:~2#~#) 3674 2852 1571 3582 1402 3331 1741 2678 2076 2685 734 261
7 7

Explanation

[:($#:I.@,)48879=4 4#.@,;._3]  Input: 2d array M
                            ]  Identity. Get M
                 4 4    ;._3   For each 4x4 subarray of M
                       ,         Flatten it
                    #.@          Convert it to decimal from binary
           48879=              Test if equal to 48879 (decimal value of beef)
[:(       )                    Operate on the resulting array
         ,                       Flatten it
      I.@                        Find the indices where true
    #:                           Convert from decimal to radix based on
   $                               The shape of that array
                               Returns the result as coordinates [y, x]
share|improve this answer

Perl, 54 bytes

53 bytes code + 1 for -n. Uses -E at no extra cost.

Uses 0-based indices. Expects input as a string of 1s and 0s and outputs space separated co-ordinates.

Thanks to @wullxz and @GabrielBenamy for helping me save 9 bytes!

/1011(.{8}1110){2}.{8}1111/;say$-[0]%12,$",$-[0]/12|0

Usage

perl -nE '/1011(.{8}1110){2}.{8}1111/;say$-[0]%12,$",$-[0]/12|0' <<< '111001111110110100100000010001111101100100100100100101100111111111000010110111000001100111100001100111011111111110011111100001010111110011000011'
3 4
share|improve this answer
1  
You can save 3 characters by combining the regex for the binary EE: (.{8}1110){2} instead of .{8}1110.{8}1110 – wullxz yesterday
1  
You can also save another 3 bytes by changing length$` into $-[0] – Gabriel Benamy 19 hours ago
    
@wullxz Of course! I tried \1 but had no luck, didn't think to try {2}! Thanks! – Dom Hastings 6 hours ago
    
@GabrielBenamy Amazing, thank you very much! Updated! – Dom Hastings 6 hours ago
1  
@User112638726 "$-[0] is the offset of the start of the last successful match. $-[n] is the offset of the start of the substring matched by n-th subpattern, or undef if the subpattern did not match." from: perldoc.perl.org/perlvar.html (look for @-) – Dom Hastings 4 hours ago

Python, 137 bytes (according to Linux (thanks ElPedro))

def f(s,q=0):import re
 i=s.index(re.findall('1011.{8}1110.{8}1110.{8}1111',s)[q])+1
 x=i%12
 y=(i-x)/12
 if x>8:x,y=f(s,q+1)
 return x,y

Not exactly a competitive bytecount, but the algorithm is a bit interesting. Takes input as a string of binary values.

share|improve this answer
    
If you sue single spaces instead of 4 and check it on Linux it's 137 – ElPedro 18 hours ago
1  
I think you need a newline and space before the import (I get an IndentError in Python 2 without it) which costs 2 bytes but you can then put i=..., x=... and y=... on the same line as and separate with ; to lose 1 byte for 136 – ElPedro 18 hours ago
    
@elpedro I'm using Python 3, and it's fine with the import being on the same line. – mnbvc 18 hours ago
    
Fully understood :) – ElPedro 18 hours ago
    
Jeez, just reread my comments and I'm making so many typos tonight. Good thing I'm not trying to write any code... – ElPedro 17 hours ago

Scala, 318 Bytes

This solution could be further improved... but I kept it readable and allowed for the input to be the multi-line spaced matrix.

Actual Solution if Array of binary String

def has(s: String, t: String): Int = s.indexOf(t)
val beef = List("1011", "1110", "1110", "1111")
l.zipWithIndex.map{case(e,i)=>l.drop(i).take(4)}.map{_.zip(beef)}.map{_.collect{case e=>has(e._1,e._2)}}.zipWithIndex.filterNot{e => e._1.contains(-1) ||  e._1.distinct.length > 1}.map{e=>s"(${e._1.head},${e._2})"}.head

Sample Working

val bun = 
"""1 1 1 0 0 1 1 1 1 1 1 0
1 1 0 1 0 0 1 0 0 0 0 0
0 1 0 0 0 1 1 1 1 1 0 1
1 0 0 1 0 0 1 0 0 1 0 0
1 0 0 1 0 1 1 0 0 1 1 1
1 1 1 1 1 1 0 0 0 0 1 0
1 1 0 1 1 1 0 0 0 0 0 1
1 0 0 1 1 1 1 0 0 0 0 1
1 0 0 1 1 1 0 1 1 1 1 1
1 1 1 1 1 0 0 1 1 1 1 1
1 0 0 0 0 1 0 1 0 1 1 1
1 1 0 0 1 1 0 0 0 0 1 1
""".replaceAll(" ","")
def has(s: String, t: String): Int = s.indexOf(t)
val beef = List("1011", "1110", "1110", "1111")
val l = bun.split("\n").toList
l.zipWithIndex.map{case(e,i)=>l.drop(i).take(4)}
.map{_.zip(beef)}
.map{_.collect{case e=>has(e._1,e._2)}}.zipWithIndex
.filterNot{e => e._1.contains(-1) ||  e._1.distinct.length > 1}
.map{e=>s"(${e._1.head},${e._2})"}.head
share|improve this answer

Element, 130 bytes

_144'{)"1-+2:';}144'["1-+19:~?1+~?!2+~?3+~?12+~?13+~?14+~?15+~?!24+~?25+~?26+~?27+~?!36+~?37+~?38+~?39+~?16'[&][12%2:`\ `-+12/`]']

Try it online!

Takes input as one long string of 1s and 0s without any delimiters. Outputs like 3 4 (0-based indexing).

This works by placing the input data into an "array" (basically a dictionary with integer keys) and then, for each possible starting value, tests the bits at particular offsets (all 16 of them in a very laborious process).

share|improve this answer

Ruby, 62 bytes

def f(a);a=~/1011(.{8}1110){2}.{8}1111/;$`.size.divmod(12);end 

It expects a string of 0 and 1 and returns an array of Y and X, zero-based.

Try at ideone.

share|improve this answer

APL, 32 bytes

⎕IO must be 1. Takes a 12x12 binary array as input and returns the coordinates in reverse order.

{0~⍨∊{⍵×⍳⍴⍵}⍵⍷⍨~2 8 12∊⍨4 4⍴⍳16}

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.