<commit_before>require 'minitest/autorun'

F=->i{l = i.lines
m = l.map(&:size).max
g = {}
l.size.times{|y|m.times{|x|l[y][x]==?+&&g[[y, x]]=[[y, x]]}}
c=->a,b{w=g[b]+g[a];w.map{|x|g[x]=w}}
k=g.keys
k.product(k).map{|n, o|
r,p=n
s,q=o
((r==s&&p<q&&l[r][p...q]=~/^\+-[|-]*$/)||(p==q&&r<s&&l[r...s].map{|l|l[p]||' '}.join=~/^\+\|[|-]*$/))&&c[n, o]}
g.values.uniq.count}


class TestAsciiTopologyCount < Minitest::Test
  def test_empty
    assert_equal 0, F['']
  end

  def test_1
    input = <<-EOS
   +---+
   |   |
+--+   |
|      |
+--+   |
   |   |<commit_msg>golfed down to 295 chars<commit_after>require 'minitest/autorun'

F=->i{l=i.lines
g={}
l.size.times{|y|i.size.times{|x|l[y][x]==?+&&g[[y,x]]=[[y,x]]}}
c=->a,b{w=g[b]+g[a];w.map{|x|g[x]=w}}
k=g.keys
k.product(k).map{|n,o|
r,p=n
s,q=o
((r==s&&p<q&&l[r][p...q]=~/^\+-[|-]*$/)||(p==q&&r<s&&l[r...s].map{|l|l[p]||c}.join=~/^\+\|[|-]*$/))&&c[n,o]}
g.values.uniq.size}


class TestAsciiTopologyCount < Minitest::Test
  def test_empty
    assert_equal 0, F['']
  end

  def test_1
    input = <<-EOS
   +---+
   |   |
+--+   |
|      |
+--+   |
   |   |
{'fraction_non_alphanumeric': 0.36675700090334235, 'fraction_numerical': 0.006323396567299007, 'mean_word_length': 3.3622047244094486, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '524429', 'n_tokens_mistral': 637, 'n_tokens_neox': 605, 'n_words': 62}