[Question]
  [
Given an image, output the [width in pixels of a full vertical section]1 (if one exists). If no vertical section exists, output `0`.
Input may be provided as a local file or a nested array. If you choose to take input as a nested array, white pixels should be represented by a truthy value while non-white pixels should be represented by a falsey value.
1. the number of contiguous, all-white columns
---
You can assume that
* no image will be larger than 1000 square pixels
* there will be no more than one full vertical section per image
---
## Examples
Inputs:
![](https://i.stack.imgur.com/AmXiR.jpg)
![](https://i.stack.imgur.com/vb2Yt.jpg)
![](https://i.stack.imgur.com/1V7QD.jpg)
![](https://i.stack.imgur.com/MqcDJ.jpg)
Outputs:
```
50
57
0
0
```
Here are the first two examples, highlighted (in yellow) to show their sections:
![](https://i.stack.imgur.com/iJAgn.jpg)
![](https://i.stack.imgur.com/aN6gC.jpg)
  
[Answer]
# Jelly, 2 bytes
```
PS
```
[Try it here!](http://jelly.tryitonline.net/#code=UFM&input=&args=W1swLDAsMCwwLDEsMSwxLDEsMSwxLDEsMSwxLDEsMCwwLDAsMCwwXSxbMCwwLDAsMCwwLDAsMCwxLDEsMSwxLDEsMSwxLDEsMSwwLDAsMF0sWzAsMCwwLDAsMCwwLDAsMCwwLDEsMSwxLDEsMSwwLDAsMCwwLDBdLFswLDAsMCwwLDAsMCwwLDAsMSwxLDEsMSwxLDAsMCwwLDAsMCwwXSxbMCwwLDAsMSwxLDEsMSwxLDEsMSwxLDEsMSwxLDEsMSwxLDAsMF0sWzAsMCwwLDAsMCwwLDEsMSwxLDEsMSwxLDAsMCwwLDAsMCwwLDBdLFswLDAsMCwwLDAsMCwwLDEsMSwxLDEsMSwxLDEsMSwwLDAsMCwwXSxbMCwwLDAsMCwxLDEsMSwxLDEsMSwxLDEsMSwxLDAsMCwwLDAsMF1d)
If I encode an image like so:
```
0000111111111100000
0000000111111111000
0000000001111100000
0000000011111000000
0001111111111111100
0000001111110000000
0000000111111110000
0000111111111100000
```
Into a nested array like this:
```
[[0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0],[0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0],...]
```
Then `P` takes the element-wise product of all of the row vectors, and `S` sums all of the ones in the result, yielding the length of the vertical slice. (This works only because there‚Äôs guaranteed to be only one contiguous slice.) In our case, the answer is `3`.
[Answer]
# APL, 4 bytes
```
+/√ó‚åø
```
`[Try it here.](http://ngn.github.io/apl/web/index.html#code=%28+/%D7%u233F%298%2019%u23740%200%200%200%201%201%201%201%201%201%201%201%201%201%200%200%200%200%200%200%200%200%200%200%200%200%201%201%201%201%201%201%201%201%201%200%200%200%200%200%200%200%200%200%200%200%200%201%201%201%201%201%200%200%200%200%200%200%200%200%200%200%200%200%200%201%201%201%201%201%200%200%200%200%200%200%200%200%200%201%201%201%201%201%201%201%201%201%201%201%201%201%201%200%200%200%200%200%200%200%200%201%201%201%201%201%201%200%200%200%200%200%200%200%200%200%200%200%200%200%200%201%201%201%201%201%201%201%201%200%200%200%200%200%200%200%200%201%201%201%201%201%201%201%201%201%201%200%200%200%200%200)`
This is my first APL answer!
Thanks to @jimmy23013 and @NBZ for saving bytes!
[Answer]
# Bash + common utilities, 17
```
rs -Tc|grep -vc 0
```
If you're not using `grep` for [image-processing](/questions/tagged/image-processing "show questions tagged 'image-processing'"), then you're doing it wrong ;-).
This uses the `rs` utility to do transposition. `rs` is [bundled in OSX](https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/rs.1.html), but will need installing in most linux with something like `sudo apt-get install rs`.
Input columns are `TAB` separated, and rows are newline separated:
```
0   0   0   0   1   1   1   1   1   1   1   1   1   1   0   0   0   0   0   
0   0   0   0   0   0   0   1   1   1   1   1   1   1   1   1   0   0   0   
0   0   0   0   0   0   0   0   0   1   1   1   1   1   0   0   0   0   0   
0   0   0   0   0   0   0   0   1   1   1   1   1   0   0   0   0   0   0   
0   0   0   1   1   1   1   1   1   1   1   1   1   1   1   1   1   0   0   
0   0   0   0   0   0   1   1   1   1   1   1   0   0   0   0   0   0   0   
0   0   0   0   0   0   0   1   1   1   1   1   1   1   1   0   0   0   0   
0   0   0   0   1   1   1   1   1   1   1   1   1   1   0   0   0   0   0
```
If you like, you can preprocess the example input images into this format with imagemagick and (GNU) sed. E.g:
```
$ for img in "AmXiR.jpg" "vb2Yt.jpg" "1V7QD.jpg" "MqcDJ.jpg" ; do
>     convert -depth 1 "$img" xpm:- | \
>     sed -nr '/pixels/{:l;n;/}/q;s/^"(.*)",?$/\1/;y/ ./01/;s/./&\t/g;p;bl}' | \
>     rs -Tc|grep -vc 0
> done
50
57
0
0
$
```
[Answer]
# Perl, ~~21~~ 22 bytes
## Fixed version
Includes +2 for `-lp` (`-l` can be omitted and would still be a valid solution, but it's ugly without the final newline)
Give sequences of 1's and 0's on 0 or more lines on STDIN.
You can add spaces or commas or whatever between the digits if you want as long as the usage is.consistent on all lines.
```
$a|=~$_}{$_=$a=~y;\xce;
```
This works as shown, but replace `\xce` by the literal byte value to get the claimed score
If there are multiple vertical sections this returns the sum of all section widths. If you want the width of **a** vertical section use
```
$a|=~$_}{$a=~/\xce+/;$_="@+"-"@-"
```
## Old version
I originally misunderstood the challenge and implemented a program that gives true or false based on if a vertical line exists at all. Code and explanation here are for this old version
```
$a|=~$_}{$_|=~$a=~1
```
If only I could add 1=~ at the left for almost perfect symmetry... I suppose the closest would be
```
1=>$a|=~$_}{$_|=~$a=~1
```
## Explanation
```
$a|=~$_     The bitwise operators in perl (&, |, ^, ~) also work on strings by 
            working on the sequence of byte values. The digits "0" and "1" happen
            to have the same ASCII value differing only in the last bit which is
            0 for "0" and 1 for "1". So I would really like to do an "&" here.
            Unfortunately "&" of two different length strings shortens the result
            to the shortest of the strings and my accumulator starts as an empty 
            string. The "|" of two strings however extends to the longest string.
            So instead I will apply De Morgan's law and use "|" on the
            complemented byte string 
}{          Standard perl golf trick. "-p code" transforms to (simplified)
            "while (<>) { code; print }". So if code is "code1 } { code2" this
            becomes "while (<>) { code1 } {code2; print }". So you can use code1
            for the loop operation, use code2 for the final calculation and get a
            free print by assigning to $_
$_|=~$a=~1  I would like to match the accumulator with the bit complement of "1",
            but $a=~~1 doesn't work because the 1 is not a string but a number.
            $a=~~"1" would work but is too long. Next up is complementing $a back
            and matching with 1, so $_=~$a=~1. That also doesn't work since the
            first =~ will be interpreted as a string match insteads of equals
            followed by complement. Easily solved by writing it as $_= ~a=~1. But
            if I am going to give up a byte I can at least have some fun with it.
            Using $_|= also makes the parse work and has the advantage that the
            failure case will give 0 instead of an empty string, which looks
            nicer. It also makes the code look very symmetric. I can also bring
            out the symmetry more by putting 1=> in front (which evaluates 1
            before the assignment and then immediately discards it)
```
[Answer]
# Python 2, 30 bytes
There is a surprisingly elegant solution using many of my favourite built-in functions chained together.
```
lambda c:sum(map(all,zip(*c)))
```
Using the test image from @Lynn:
```
>>> image = [[0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]]
>>> func = lambda c:sum(map(all,zip(*c)))
>>> func(image)
3
```
[Answer]
# Pyth, 5
```
s*VFQ
```
[Try it here](http://pyth.herokuapp.com/?code=s%2AVFQ&input=%5B%5B0%2C%200%2C%200%2C%200%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%200%2C%200%2C%200%2C%200%2C%200%5D%2C%20%5B0%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%200%2C%200%2C%200%5D%2C%20%5B0%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%2C%201%2C%201%2C%201%2C%201%2C%201%2C%200%2C%200%2C%200%2C%200%2C%200%5D%2C%20%5B0%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%2C%201%2C%201%2C%201%2C%201%2C%201%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%5D%2C%20%5B0%2C%200%2C%200%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%200%2C%200%5D%2C%20%5B0%2C%200%2C%200%2C%200%2C%200%2C%200%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%5D%2C%20%5B0%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%200%2C%200%2C%200%2C%200%5D%2C%20%5B0%2C%200%2C%200%2C%200%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%200%2C%200%2C%200%2C%200%2C%200%5D%5D&debug=0)
This uses Lynn's algorithm, but I decided to post it just to show how to golf vector operations in Pyth. The trick here is to chain the "sugar" syntax helpers `V` and `F` so that the fold is applied as a vector operation. The operator that is folded is of course multiplication, and then the result is summed to get the final answer.
[Answer]
## JavaScript (ES6), ~~54~~ ~~45~~ 43 bytes
```
a=>a[s=0].map((_,i)=>s+=a.every(b=>b[i]))|s
a=>a[s=0].map((_,i)=>s+=!a.some(b=>b[i]))|s
```
Based on @Lynn's Jelly answer, though since golfed by using `every` or `some` instead of `reduce`. The first version encodes black = 0 while the second encodes black = 1.
Edit: Saved 2 further bytes thanks to @edc65.
[Answer]
# [J](http://jsoftware.com/), ~~5~~ 6 bytes
Takes Boolean matrix as argument.
```
[:+/*/
```
This is my first J answer! (was wrong for 1¬Ω years‚Ä¶)
`*/`‚ÄÉcolumnwise product
`+/`‚ÄÉsum
`[:`‚ÄÉcap (serves as placeholder since `+/` should not take a left argument)
[Try it online!](https://tio.run/##y/r/P83WKtpKW19L/39qcka@QoGtlbGCmYqBgiEYGgAhmIJxwSIQpiEXWEeaQsF/AA "J ‚Äì Try It Online")
[Answer]
# CJam, 7 bytes
```
q~:.*:+
```
[**Try it online!**](http://cjam.tryitonline.net/#code=cX46Lio6Kw&input=W1swIDAgMCAwIDEgMSAxIDEgMSAxIDEgMSAxIDEgMCAwIDAgMCAwXSBbMCAwIDAgMCAwIDAgMCAxIDEgMSAxIDEgMSAxIDEgMSAwIDAgMF0gWzAgMCAwIDAgMCAwIDAgMCAwIDEgMSAxIDEgMSAwIDAgMCAwIDBdIFswIDAgMCAwIDAgMCAwIDAgMSAxIDEgMSAxIDAgMCAwIDAgMCAwXSBbMCAwIDAgMSAxIDEgMSAxIDEgMSAxIDEgMSAxIDEgMSAxIDAgMF0gWzAgMCAwIDAgMCAwIDEgMSAxIDEgMSAxIDAgMCAwIDAgMCAwIDBdIFswIDAgMCAwIDAgMCAwIDEgMSAxIDEgMSAxIDEgMSAwIDAgMCAwXSBbMCAwIDAgMCAxIDEgMSAxIDEgMSAxIDEgMSAxIDAgMCAwIDAgMF1d)
```
q~      e# read input and evaluate: push nested array
:.*     e# fold vectorized product over nested array: element-wise product of rows
:+      e# fold addition over array: compute its sum
```
[Answer]
## Mathematica 24
```
Length@Cases[Total@#,0]&
```
Takes an array in the following form:
```
{{1, 0, 0, 0, 1, 0},
{1, 0, 0, 1, 1, 1},
{1, 1, 0, 0, 0, 0},
{1, 1, 0, 0, 1, 1},
{1, 0, 0, 1, 1, 1}}
```
And in this case outputs:
```
1
```
[Answer]
# ùîºùïäùïÑùïöùïü, 7 chars / 9 bytes
```
‚®≠–ú∆ü√Ø‚ìú‚®¥$
```
`[Try it here (Firefox only).](http://molarmanful.github.io/ESMin/interpreter3.html?eval=true&input=%5B%5B0%2C0%2C0%2C0%2C1%2C1%2C1%2C1%2C1%2C1%2C1%2C1%2C1%2C1%2C0%2C0%2C0%2C0%2C0%5D%2C%5B0%2C0%2C0%2C0%2C0%2C0%2C0%2C1%2C1%2C1%2C1%2C1%2C1%2C1%2C1%2C1%2C0%2C0%2C0%5D%2C%5B0%2C0%2C0%2C0%2C0%2C0%2C0%2C0%2C0%2C1%2C1%2C1%2C1%2C1%2C0%2C0%2C0%2C0%2C0%5D%2C%5B0%2C0%2C0%2C0%2C0%2C0%2C0%2C0%2C1%2C1%2C1%2C1%2C1%2C0%2C0%2C0%2C0%2C0%2C0%5D%2C%5B0%2C0%2C0%2C1%2C1%2C1%2C1%2C1%2C1%2C1%2C1%2C1%2C1%2C1%2C1%2C1%2C1%2C0%2C0%5D%2C%5B0%2C0%2C0%2C0%2C0%2C0%2C1%2C1%2C1%2C1%2C1%2C1%2C0%2C0%2C0%2C0%2C0%2C0%2C0%5D%2C%5B0%2C0%2C0%2C0%2C0%2C0%2C0%2C1%2C1%2C1%2C1%2C1%2C1%2C1%2C1%2C0%2C0%2C0%2C0%5D%2C%5B0%2C0%2C0%2C0%2C1%2C1%2C1%2C1%2C1%2C1%2C1%2C1%2C1%2C1%2C0%2C0%2C0%2C0%2C0%5D%5D&code=%E2%A8%AD%D0%9C%C6%9F%C3%AF%E2%93%9C%E2%A8%B4%24)`
This is @Lynn's great algorithm, but I found it independently. (I thought there was a builtin for this somewhere, still looking :P)
# Explanation
`–ú∆ü√Ø` transposes the input array, `‚ìú‚®¥$` turns each inner vector into its product, and `‚®≠` sums the resulting array.
[Answer]
# [Japt](https://github.com/ETHproductions/japt/), ~~6~~ 4 bytes
Takes input as an array of rows, with `1` being white and `0` being black.
```
y xe
```
* 2 bytes saved thanks to [ETH](https://codegolf.stackexchange.com/users/42545/ethproductions).
[Test it](http://ethproductions.github.io/japt/?v=1.4.5&code=eSCu18N4&input=W1swLDAsMCwwLDEsMSwxLDEsMSwxLDEsMSwxLDEsMCwwLDAsMCwwXSxbMCwwLDAsMCwwLDAsMCwxLDEsMSwxLDEsMSwxLDEsMSwwLDAsMF0sWzAsMCwwLDAsMCwwLDAsMCwwLDEsMSwxLDEsMSwwLDAsMCwwLDBdLFswLDAsMCwwLDAsMCwwLDAsMSwxLDEsMSwxLDAsMCwwLDAsMCwwXSxbMCwwLDAsMSwxLDEsMSwxLDEsMSwxLDEsMSwxLDEsMSwxLDAsMF0sWzAsMCwwLDAsMCwwLDEsMSwxLDEsMSwxLDAsMCwwLDAsMCwwLDBdLFswLDAsMCwwLDAsMCwwLDEsMSwxLDEsMSwxLDEsMSwwLDAsMCwwXSxbMCwwLDAsMCwxLDEsMSwxLDEsMSwxLDEsMSwxLDAsMCwwLDAsMF1d)
---
## Explanation
```
y xe
          :Implicit input of array U.
y         :Transpose.
   e      :Map over each sub-array, checking if every element is truthy.
  x       :Reduce by summing, converting booleans to 1 or 0.
          :Implicit output of resulting integer.
```
]