Find the haystack in the needles
Ruby, 207
-&gt;a{d=-&gt;b{0...b.size}
f=c=s=-&gt;y,x{(d[a]===y&amp;&amp;d[a[0]]===x&amp;&amp;!f[y][x]&amp;&amp;a[y][x]==c)?(c,f[y][x]=?#,1
1+s[y,x-1]+s[y,x+1]+s[y-1,x]+s[y+1,x]):0}
d[a].map{|y|d[y].map{|x|f,c=a.map{|b|b.map{p}},?N
s[y,x]}.max}.max-1}

This is an anonymous function that takes in the input as an array of arrays. Usage:
f=-&gt;a{......}

f[&quot;
N##
NN#
#NN
#N#
&quot;.strip.split.map(&amp;:chars)] # =&gt; 4

The proc named s recursively finds the size of the haystack with needle at specific coordinates and is called on each needle in the haystack.