Box Overlap

Detect which box is on top.
Print the ID of that box.
Where no edges overlap, print 'None'
The ID of the box is the character top left.

IN

a-+
|b|+
+-+|
 +-+

OUT

a

IN

1------+
|      |
|      |
|   2-------+
|   |  |    |
+---|--+    |
    |       |
    +-------+

OUT

2

IN

1------+
|      |
|      |
|   2--|----+
|   |  |    |
+------+    |
    |       |
    +-------+

OUT

1

IN

a--+
|  |
+--+

    b-+
    | |
    +-+

OUT

None

IN

6----------------------------+7---+
|                            ||   |
+----------------------------++---+

OUT

None

IN

       X------+
       |      |
       |      |
       +------+
Y------+
|      |
|      |
+------+

OUT

None

IN

       X------+
       |      |
 Y-----|+     |
 |     +------+
 |      |
 +------+

OUT

X

IN

        X------+
        |      |
  Y------+     |
  |     +|-----+
  |      |
  +------+

OUT

Y

IN

1------+
|      |
| a-+  |
| | |  |
| +-+  |
+------+

OUT

None

IN

a-+
|b-+
+|+|
 +-+

OUT

b
Login to submit solution


38 symbols pyth
Wed Oct 19 06:53:16 2016 Sait2000
.xhh:jb.z"\w\S+[^\w+]*[\w+]-*\|"1"None
45 symbols pyth
Wed Oct 19 06:41:43 2016 Sait2000
V:jb.z"[\\w+].+?\\+"1 aYhNI}\|NJ@Y_2;.xJ"None
75 symbols perl
Fri Sep 26 14:24:31 2014 vakorol
#!/usr/bin/perl -n
push(@a,$1),$b||=/\S\|/&&$a[-2],@a>3&&print$b||'None'while/(\w|\+).+?\+/g
77 symbols perl
Fri Sep 26 14:18:27 2014 vakorol
#!/usr/bin/perl -n
while(/(\w|\+).+?\+/g){push@a,$1;$b||=/\S\|/&&$a[-2];@a>3&&print$b||'None'}
80 symbols perl
Mon Aug 25 04:10:18 2014 gabrielmad
#!/usr/bin/perl -p0
@x=/\w/g;/\|/?last:$i++for/((?:\w|\+)(?:-|\|)+\+)/g;$_=$i>3?'None':$x[++$i%2]
138 symbols perl
Sun Aug 3 01:32:33 2014 danieljabailey
#!/usr/bin/perl -n
$d=' *([^- |+])-*';/^$d\+/;$i||=$1;$p=/^$d\+ *\|| *\|$d\+$/?$1.$2:/$d\|-*\+| *\| $d\|-*\+/?$i:/^ *\+-*\+/?'None':'';if($p){print$p;exit}
138 symbols perl
Sun Aug 3 01:34:21 2014 danieljabailey
#!/usr/bin/perl -n
$d=' *([^- |+])-*';/^$d\+/;$i||=$1;$p=/^$d\+ *\|| *\|$d\+$/?$1.$2:/$d\|-*\+| *\| $d\|-*\+/?$i:/^ *\+-*\+/?'None':'';if($p){print$p;exit}
141 symbols perl
Sun Aug 3 01:31:14 2014 danieljabailey
#!/usr/bin/perl -n
$d='*([^- |+])-*';/^ $d\+/;$i||=$1;$p=/^ $d\+ *\|| *\| $d\+$/?$1.$2:/ $d\|-*\+| *\| $d\|-*\+/?$i:/^ *\+-*\+/?'None':'';if($p){print$p;exit}
145 symbols perl
Sun Aug 3 01:28:33 2014 danieljabailey
#!/usr/bin/perl -n
$d='([^- |+])-*';/^ *$d\+/;$i||=$1;$p=/^ *$d\+ *\|| *\| *$d\+$/?$1.$2:/ *$d\|-*\+| *\| *$d\|-*\+/?$i:/^ *\+-*\+/?'None':'';if($p){print$p;exit}
146 symbols perl
Sun Aug 3 01:03:17 2014 danieljabailey
#!/usr/bin/perl -n
$d='([^- |+])-*';/^ *$d-\+/;$i||=$1;$p=/^ *$d\+ *\|| *\| *$d\+$/?$1.$2:/ *$d\|-*\+| *\| *$d\|-*\+/?$i:/^ *\+-*\+/?'None':'';if($p){print$p;exit}
151 symbols perl
Sat Aug 2 23:00:14 2014 avkhozov
#!/usr/bin/perl -n
$d='([^- |+])-*';/^ *$d-\+/;$i||=$1;$p=/^ *$d\+ *\|| *\| *$d\+$/?$1?$1:$2:/ *$d\|-*\+| *\| *$d\|-*\+/?$i:/^ *\+-*\+/?'None':'';if($p){print$p;exit}

153 symbols perl
Sat Aug 2 22:58:51 2014 avkhozov
#!/usr/bin/perl -n
$d='([^- |+])-*';/^ *$d-\+/;$i=$i?$i:$1;$p=/^ *$d\+ *\|| *\| *$d\+$/?$1?$1:$2:/ *$d\|-*\+| *\| *$d\|-*\+/?$i:/^ *\+-*\+/?'None':'';if($p){print$p;exit}
157 symbols perl
Sat Aug 2 22:48:10 2014 danieljabailey
#!/usr/bin/perl -n
$d='([^- |+])-*';m/^ *$d-\+/;$i=$i?$i:$1;$p=m/^ *$d\+ *\|| *\| *$d\+$/?$1?$1:$2:m/ *$d\|-*\+| *\| *$d\|-*\+/?$i:m/^ *\+-*\+/?'None':'';if($p){print$p;exit}
161 symbols perl
Sat Aug 2 21:14:10 2014 danieljabailey
#!/usr/bin/perl -n
$d='([^- |+])-*';m/^ *$d-\+/;$i=$i?$i:$1;$p=m/^ *$d\+ *\|| *\| *$d\+$/?($1?$1:$2):m/ *$d\|-*\+| *\| *$d\|-*\+/?$i:(m/^ *\+-*\+/?'None':'');if($p){print$p;exit}
171 symbols perl
Sat Aug 2 21:06:43 2014 danieljabailey
#!/usr/bin/perl -n
$d='([^- |+])-*';m/^ *$d-\+/;$i=$i?$i:$1;$p=$1?$1:$2 if(m/^ *$d\+ *\|| *\| *$d\+$/);$p=$i if(m/ *$d\|-*\+| *\| *$d\|-*\+/);$p='None'if(m/^ *\+-*\+/);if($p){print$p;exit}
177 symbols perl
Sat Aug 2 21:05:26 2014 danieljabailey
#!/usr/bin/perl -n
$id='([^- |+])-*';m/^ *$id-\+/;$i=$i?$i:$1;$p=$1?$1:$2 if(m/^ *$id\+ *\|| *\| *$id\+$/);$p=$i if(m/ *$id\|-*\+| *\| *$id\|-*\+/);$p='None'if(m/^ *\+-*\+/);if($p){print$p;exit}
178 symbols perl
Sat Aug 2 21:04:36 2014 danieljabailey
#!/usr/bin/perl -n
$id='([^- |+])-*';m/^ *$id-+\+/;$i=$i?$i:$1;$p=$1?$1:$2 if(m/^ *$id\+ *\|| *\| *$id\+$/);$p=$i if(m/ *$id\|-*\+| *\| *$id\|-*\+/);$p='None'if(m/^ *\+-*\+/);if($p){print$p;exit}
181 symbols perl
Sat Aug 2 21:03:55 2014 danieljabailey
#!/usr/bin/perl -n
$id='([^- |+])-*';m/^ *([^|])-+\+/;$i=$i?$i:$1;$p=$1?$1:$2 if(m/^ *$id\+ *\|| *\| *$id\+$/);$p=$i if(m/ *$id\|-*\+| *\| *$id\|-*\+/);$p='None'if(m/^ *\+-*\+/);if($p){print$p;exit}
195 symbols perl
Sat Aug 2 21:01:59 2014 danieljabailey
#!/usr/bin/perl -n
m/^ *([^|])-+\+/;$i=$i?$i:$1;$p=$1?$1:$2 if(m/^ *([^- |+])-*\+ *\|| *\| *([^- |+])-*\+$/);$p=$i if(m/ *([^- |+])-*\|-*\+| *\| *([^- |+])-*\|-*\+/);$p='None'if(m/^ *\+-*\+/);if($p){print$p;exit}
407 symbols haskell
Wed Mar 18 06:42:47 2015 YoshikuniJujo
import Data.List
main=interact$s.c.lines
f=findIndices
e=(`notElem`" +-|")
v=filter
p=concatMap
t=takeWhile
d=drop
n=length
w=(/='+')
s r@[_] = r
s _ = "None"
a=all
c m=map fst.v(h.(l m))$zip(p(v e.(m!!))y).zip(cycle y)$p(f e.(m!!))y where y=f(any e)m
l m(c,(y,x))=([o,t w.d(x+1)$m!!(y+n a+1)],[a,t w.d(y+1)$map(!!(x+n o+1))m])where o=t w.d(x+1)$m!!y;a=t w.d(y+1)$map(!!x)m
h(r,w)=a(a(=='-'))r&&a(a(=='|'))w

View all solutions