<commit_before>require_relative 'experiments/animals'
require 'minitest/autorun'


def get_placements(a)
  l = a.join(?o*(5-w=a[0].size))
  (0..25-l.size).select{|i|i/5==(i+w-1)/5}.map{|i|(?o*i+l+?o*25)}
end

def heatmap(q)
  q[0].size.times.map{|i|q.count{|p|p[i]<?o}}
end

F=->a{
  q = get_placements a

  s = ?o*25

  while q.any?
    h=heatmap(q)
    s[c=h.index(h.max)]=?X
    q.reject!{|p|p[c]<?o}
  end

  s.scan /.{5}/
}

describe 'solver returns optimum number of moves' do
  def test_optimal
    assert_equal 4, solution_block_count(MONKEY)
    assert_equal 9, solution_block_count(AATXE)
    assert_equal 3, solution_block_count(LUNAR_TICK)
    assert_equal 4, solution_block_count(RACCOON)
    assert_equal 10, solution_block_count(MARSHMALLOW)
    assert_equal 3, solution_block_count(WOOLY_RHINO)
    assert_equal 4, solution_block_count(GORILLA)
    assert_equal 4, solution_block_count(HIPPO)
    assert_equal 5, solution_block_count(PLATYPUS)
    assert_equal 4, solution_block_count(BEAR)
    assert_equal 3, solution_block_count(ZEBRA)<commit_msg>inlined external methods<commit_after>require_relative 'experiments/animals'
require 'minitest/autorun'

F=
->a{
l=a.join(?o*(5-w=a[0].size))
s=?o*25
q=(0..25-l.size).select{|i|i/5==(i+w-1)/5}.map{|i|(?o*i+l+s)}
while q.any?
h=q[0].size.times.map{|i|q.count{|p|p[i]<?o}}
s[c=h.index(h.max)]=?X
q.reject!{|p|p[c]<?o}
end
s.scan /.{5}/
}

describe 'solver returns optimum number of moves' do
  def test_optimal
    assert_equal 4, solution_block_count(MONKEY)
    assert_equal 9, solution_block_count(AATXE)
    assert_equal 3, solution_block_count(LUNAR_TICK)
    assert_equal 4, solution_block_count(RACCOON)
    assert_equal 10, solution_block_count(MARSHMALLOW)
    assert_equal 3, solution_block_count(WOOLY_RHINO)
    assert_equal 4, solution_block_count(GORILLA)
    assert_equal 4, solution_block_count(HIPPO)
    assert_equal 5, solution_block_count(PLATYPUS)
    assert_equal 4, solution_block_count(BEAR)
    assert_equal 3, solution_block_count(ZEBRA)
{'fraction_non_alphanumeric': 0.14405525407005426, 'fraction_numerical': 0.0246669955599408, 'mean_word_length': 5.317757009345795, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '2652848', 'n_tokens_mistral': 906, 'n_tokens_neox': 844, 'n_words': 132}