<commit_before>require 'mathn'

class Dna
  attr_reader :genes

  @@ALPHABET = ('a'..'z').to_a + [' ']
  @@TARGET_PHRASE = 'to be or not to be'

  def initialize
    @genes = @@TARGET_PHRASE.length.times.map { random_letter }.join
  end

  def fitness
    number_of_letters_in_correct_position = 0

    @genes.chars.each_index do |index|
      number_of_letters_in_correct_position += 1 if character_in_correct_position? index
    end

    number_of_letters_in_correct_position / @@TARGET_PHRASE.length
  end

  def crossover partner
    @genes.chars.each_index { |index| [self, partner].sample.genes[index] }.join
  end

private<commit_msg>Change interface<commit_after>require 'mathn'

class Dna
  attr_reader :genes

  @@ALPHABET = ('a'..'z').to_a + [' ']
  @@TARGET_PHRASE = 'to be or not to be'

  def initialize
    @genes = @@TARGET_PHRASE.length.times.map { random_letter }.join
  end

  def fitness
    number_of_letters_in_correct_position = 0

    @genes.chars.each_index do |index|
      number_of_letters_in_correct_position += 1 if character_in_correct_position? index
    end

    number_of_letters_in_correct_position / @@TARGET_PHRASE.length
  end

  def crossover partner
    child = Dna.new
    child.genes = @genes.chars.each_index { |index| [self, partner].sample.genes[index] }.join
    child
  end

private
{'fraction_non_alphanumeric': 0.10233258088788563, 'fraction_numerical': 0.0030097817908201654, 'mean_word_length': 3.7841726618705036, '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': '163582', 'n_tokens_mistral': 504, 'n_tokens_neox': 456, 'n_words': 100}