<commit_before>require 'test/unit'
extend Test::Unit::Assertions

class Fixnum
    def pow_3?
        chars = self.to_s.chars
        return true if self == 3 || self == 0
        return (chars.last == '1' ||
                chars.last == "3" ||
                chars.last == "9" ||
                chars.last == "7") &&
                chars.map { |c| c.to_i }.reduce(:+) % 9 == 0
    end

    def pow_3_n?
        x = self

        while x > 1
            return false if x % 3 != 0
            x /= 3
        end

        return true
    end
end

3.upto(2 ** (0.size * 2)).each { |i|
        assert_equal(i.pow_3_n?, i.pow_3?, "For #{i}")
}<commit_msg>Simple version - power of 3<commit_after>require 'test/unit'
extend Test::Unit::Assertions

class Fixnum
    def pow_3?
        return 3486784401 % self == 0
    end

    def pow_3_n?
        x = self

        while x % 3 == 0
            x /= 3
        end

        return x == 1
    end
end

3.upto(34867).each { |i|
        assert_equal(i.pow_3_n?, i.pow_3?, "For #{i}")
}
{'fraction_non_alphanumeric': 0.13980582524271845, 'fraction_numerical': 0.04466019417475728, 'mean_word_length': 1.5146341463414634, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '3182877', 'n_tokens_mistral': 400, 'n_tokens_neox': 359, 'n_words': 100}