Erlang Binary Gap
-module(binary_gap).
-export([binary_gap/1]).
binary_gap(N) ->
Bin = integer_to_list(N, 2),
Trimmed = string:trim(Bin, both, "0"),
Groups = string:split(Trimmed, "1", all),
lists:max([length(G) || G <- Groups]).
This turns the number into binary, ignores zeroes outside the edges, and finds the longest run of zeroes between 1s.