<commit_before>require 'pp'
require 'minitest/autorun'

# ideas: 
#  - replace r(Hash) with simply vars j, k
#  - more efficient loops on line #2


F=
->g,w,h{m=->y,x,d,v=[]{r=->s{g[[0,y].max...y+h].map{|l|l[[0,x].max...x+w]}.join.count s}
j=r[?>]-r[?<]
k=r[?v]-r[?^]
q=y,x
q[d=[d,1,0][j*j<=>k*k]]+=[k,j][d]<=>0
v&[q]!=[]?q!=v[-1]:m[*q,d,v<<q]}
m[0,0,1]}

describe :X do
  describe 'g 1 (2x2)' do
    before do
      @g = [
        '>v',
        '^<' ]
    end
<commit_msg>Ventero: fix incorrect cycle detection<commit_after>require 'pp'
require 'minitest/autorun'

# ideas: 
#  - replace r(Hash) with simply vars j, k
#  - more efficient loops on line #2


F=
->g,w,h{m=->y,x,d,v=[]{r=->s{g[[0,y].max...y+h].map{|l|l[[0,x].max...x+w]}.join.count s}
j=r[?>]-r[?<]
k=r[?v]-r[?^]
q=y,x
q[d=[d,1,0][j*j<=>k*k]]+=[k,j][d]<=>0
v&[q<<d]!=[]?q!=v[-1]:m[*q,v<<q]}
m[0,0,1]}

describe :X do
  describe 'g 1 (2x2)' do
    before do
      @g = [
        '>v',
        '^<' ]
    end

{'fraction_non_alphanumeric': 0.32098765432098764, 'fraction_numerical': 0.026748971193415638, 'mean_word_length': 3.4027149321266967, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '6546440', 'n_tokens_mistral': 534, 'n_tokens_neox': 519, 'n_words': 84}