10
You may have seen puzzles like this:
Find the
0:
OOOOOOOOOOOOOOOOOOOO0OOOOOOOOOOOOOOOOOO
The challenge is to write a program that finds the index of the different letter given an image.
Input
Input will be an Image. The image will consist of one line of black text in the Helvetica 24 pt. font on a white background. The text will consist from a selection of two characters: one character that is repeated, and one character that appears only once. For instance:
Output
Output will be an Integer, the index of the different character. In the example above, the output will be 4. (Note that indices of a string start at 0)
Program Specifications
As per usual for code golf, the shortest program wins.
Test Cases
=> 10
=> 11
=> 5
=> 16
=> 10
=> 21
=> 20
=> 13
=> 11
=> 4
=> 7

2Pedantic note: your real-world example isn't a puzzle per se. It's more of an amusing eye-game. – Zach Gates – 2016-03-02T01:59:11.670
How is this scored? – intboolstring – 2016-03-02T02:54:34.817
It's a code golf, so the shortest program that successfully outputs the answer to each of the examples. – AMACB – 2016-03-02T02:57:46.697
Will the difference ever be at the beginning? – CalculatorFeline – 2016-03-02T03:01:33.510
Yes, it can be there, although none are included in the examples. – AMACB – 2016-03-02T03:13:38.543
2Note that the shortest answer for some languages may actually be hard-coding the results and choosing one based on something like the size of the input image (which I assume is not allowed). – user81655 – 2016-03-02T04:27:25.923
1@AMACB "although none are included in the examples", then it might be a good idea to change that ;). Also what's the minimum number of characters we have to handle? (At least 3 I guess, or can we assume it's more than that?) There should also be a test case for that minimum. – Martin Ender – 2016-03-02T08:16:27.490
(Pity that the input is an image and not a string...) – Luis Mendo – 2016-03-02T10:12:22.210
will there always be at least one completely white column of pixels between characters? – Adám – 2016-03-02T12:06:01.963