<commit_before># BinaryGap
#
# Find longest sequence of zeros in binary representation of an integer.
#
module Codility
  module Lesson1
    def self.solution(n)
      matched_binary = n.to_s(2).match(/1.*1/)

      if matched_binary
        binary = matched_binary[0]
        sequences_of_zeros = binary.split(/1+/)
        sequences_of_zeros.map(&:size).max || 0
      else
        0
      end
    end
  end<commit_msg>Refactor Lesson 1<commit_after># BinaryGap
#
# Find longest sequence of zeros in binary representation of an integer.
#
module Codility
  module Lesson1
    def self.solution(n)
      binary = n.to_s(2)[/1.*1/] || ""
      sequences_of_zeros = binary.split(/1+/)
      sequences_of_zeros.map(&:size).max || 0
    end
  end
{'fraction_non_alphanumeric': 0.10767160161507403, 'fraction_numerical': 0.020188425302826378, 'mean_word_length': 2.7386934673366836, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6853465', 'n_tokens_mistral': 256, 'n_tokens_neox': 245, 'n_words': 62}