<commit_before>class Rails:

    def __init__(self, message, num_rails):
        self.message = message
        self.num_rails = num_rails
        self.rails = [[] for _ in range(self.num_rails)]
        self.rails_index = 0
        self.rails_index_increasing = True
        self.build_rails()

    def build_rails(self):
        for data in self.message:
            self.rails[self.rails_index].append(data)
            self.increment_rails_index()

    def increment_rails_index(self):
        self.rails_index_reverse_direction()
        if self.rails_index_increasing:
            self.rails_index += 1
        else:
            self.rails_index -= 1

    def rails_index_reverse_direction(self):
        if self.rails_index == 0:
            self.rails_index_increasing = True
        elif self.rails_index == self.num_rails - 1:
            self.rails_index_increasing = False


class RailsFenceCipher:

    def __init__(self, message, num_rails):
        self.rails = Rails(message, num_rails)

    def encode(self):
        return ''.join([data for rail in self.rails.rails for data in rail])

    def decode(self):
        return False


def encode(message, num_rails):
    return RailsFenceCipher(message, num_rails).encode()


def decode(message, num_rails):
    return RailsFenceCipher(message, num_rails).decode()<commit_msg>rail_fence_cipher: work in progress<commit_after>class Rails:

    def __init__(self, message, num_rails):
        self.message = message
        self.num_rails = num_rails
        self.reset()
        self.rails = [[] for _ in range(self.num_rails)]
        self.build_rails()

    def build_rails(self):
        for data in self.message:
            self.rails[self.rails_index].append(data)
            self.increment_rails_index()

    def increment_rails_index(self):
        self.rails_index_reverse_direction()
        if self.rails_index_increasing:
            self.rails_index += 1
        else:
            self.rails_index -= 1

    def rails_index_reverse_direction(self):
        if self.rails_index == 0:
            self.rails_index_increasing = True
        elif self.rails_index == self.num_rails - 1:
            self.rails_index_increasing = False

    def reset(self):
        self.rails_index = 0
        self.rails_index_increasing = True


class RailsFenceCipher:

    def __init__(self, message, num_rails):
        self.message = message
        self.num_rails = num_rails
        self.rails = Rails(message, num_rails)

    def encode(self):
        return ''.join([data for rail in self.rails.rails for data in rail])

    def decode(self):
        output_message = list(self.message)
        output_rails = [[] for _ in range(self.num_rails)]
        rail_lengths = [len(rail) for rail in self.rails.rails]
        for index in xrange(len(output_rails)):
            for rail_length in xrange(rail_lengths[index]):
                output_rails[index].append(output_message.pop(0))
        original_message = ''.join([data for rail in output_rails for data in rail])
        temp_rails = Rails(original_message, self.num_rails)
        return ''.join([data for rail in temp_rails.rails for data in rail])


def encode(message, num_rails):
    return RailsFenceCipher(message, num_rails).encode()


def decode(message, num_rails):
    return RailsFenceCipher(message, num_rails).decode()
{'fraction_non_alphanumeric': 0.09332140727489564, 'fraction_numerical': 0.003279666070363745, 'mean_word_length': 2.63882863340564, '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': '6430375', 'n_tokens_mistral': 1112, 'n_tokens_neox': 970, 'n_words': 225}