Mathematica 9、108バイト
c[f_,s_]:=1+First@Total@MapIndexed[#1*256^(4-#2)&,First@Abs@Differences@ToExpression@StringSplit[{f,s},"."]]
ゴルフをしていない:
countIpAddresses[first_, second_] := Module[{digitArrays, differences},
(* Split the strings and parse them into numbers.
Mathematica automatically maps many/most of its functions across/
through lists *)
digitArrays = ToExpression[StringSplit[{first, second}, "."]];
(* Find the absolute value of the differences of the two lists,
element-wise *)
differences = Abs[Differences[digitArrays]];
(* differences looks like {{4, 4, 4, 4}} right now,
so take the first element *)
differences = First[differences];
(* now map a function across the differences,
taking the nth element (in code, '#2') which we will call x (in
code, '#1') and setting it to be equal to (x * 256^(4-n)).
To do this we need to track the index, so we use MapIndexed.
Which is a shame,
because Map can be written '/@' and is generally a huge character-
saver. *)
powersOf256 = MapIndexed[#1*256^(4 - #2) &, differences];
(* now we essentially have a list (of singleton lists,
due to MapIndexed quirk) which represents the digits of a base-256,
converted to decimal form.
Example: {{67108864},{262144},{1024},{4}}
We add them all up using Total,
which will give us a nested list as such: {67372036}
We need to add 1 to this result no matter what. But also,
to be fair to the challenge, we want to return a number -
not a list containing one number.
So we take the First element of our result. If we did not do this,
we could chop off 6 characters from our code. *)
1 + First[Total[powersOf256]]
]