<commit_before>"""
Project Euler - Problem 11
http://projecteuler.net/problem=11
"""

import time
import numpy as np  # please install numpy module (python-numpy on Arch Linux)


def fill_matrix():
    """
    Return a numpy matrix from the data in problem11-data.txt
    """
    array = []
    with open('problem11-data.txt', 'r') as f:
        for line in f:
            array.append(line.strip())

    # this is just a 2d array, not a matrix
    matrixarray = np.loadtxt('problem11-data.txt', delimiter=' ')
    # this is a matrix
    npmatrix = np.bmat(matrixarray)
    return npmatrix


def largest_product_horizontally(matrix):
    """
    Computes the largest product horizontally (line by line) on a given matrix
    """
    product = 1
    largest_product = 1
    for line in range(0, matrix.shape[0]):  # for each line
        for column in range(0, matrix.shape[0]-3):  # for each column
            product = int(matrix[line, column] *
                          matrix[line, column+1] *
                          matrix[line, column+2] *
                          matrix[line, column+3])
            if product > largest_product:
                largest_product = product
        product = 1
    return largest_product


def largest_product_vertically(matrix):
    """
    Computes the largest product vertically (column by column)
    on a given matrix
    """
    matrix_vert = np.rot90(matrix)
    return largest_product_horizontally(matrix_vert)


def largest_product_diagonally(matrix):
    """
    Computes the largest product diagonally (NW, NE, SE, SW)
    on a given value [x, y]
    """
    product_NW = 1
    product_NE = 1
    product_SE = 1
    product_SW = 1
    max_product = 1
    largest_product = 1
    for line in range(0, matrix.shape[0]):  # for each line
        for column in range(0, matrix.shape[0]):  # for each column
            try:
                # NW
                product_NW = int(matrix[line, column] *
                                 matrix[line-1, column-1] *
                                 matrix[line-2, column-2] *<commit_msg>Solution for problem 11<commit_after>"""
Project Euler - Problem 11
http://projecteuler.net/problem=11
"""

import time
import numpy as np  # please install numpy module (python-numpy on Arch Linux)


def fill_matrix():
    """
    Return a numpy matrix from the data in problem11-data.txt
    """
    array = []
    with open('problem11-data.txt', 'r') as f:
        for line in f:
            array.append(line.strip())

    # this is just a 2d array, not a matrix
    matrixarray = np.loadtxt('problem11-data.txt', delimiter=' ')
    # this is a matrix
    npmatrix = np.bmat(matrixarray)
    return npmatrix


def largest_product_horizontally(matrix):
    """
    Computes the largest product horizontally (line by line) on a given matrix
    """
    product = 1
    largest_product = 1
    for line in range(0, matrix.shape[0]):  # for each line
        for column in range(0, matrix.shape[0]-3):  # for each column
            product = int(matrix[line, column] *
                          matrix[line, column+1] *
                          matrix[line, column+2] *
                          matrix[line, column+3])
            if product > largest_product:
                largest_product = product
        product = 1
    return largest_product


def largest_product_vertically(matrix):
    """
    Computes the largest product vertically (column by column)
    on a given matrix
    """
    matrix_vert = np.rot90(matrix)  # rotating the matrix
    return largest_product_horizontally(matrix_vert)


def largest_product_diagonally(matrix):
    """
    Computes the largest product diagonally (NW, NE, SE, SW)
    on a given value [x, y]
    """
    product_NW = 1
    product_NE = 1
    product_SE = 1
    product_SW = 1
    max_product = 1
    largest_product = 1
    for line in range(0, matrix.shape[0]):  # for each line
        for column in range(0, matrix.shape[0]):  # for each column
            try:
                # NW
                product_NW = int(matrix[line, column] *
                                 matrix[line-1, column-1] *
                                 matrix[line-2, column-2] *
{'fraction_non_alphanumeric': 0.0960209673576364, 'fraction_numerical': 0.01858470335954253, 'mean_word_length': 2.0799706529713866, 'pattern_counts': {'":': 0, '<': 3, '<?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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '858595', 'n_tokens_mistral': 1281, 'n_tokens_neox': 1196, 'n_words': 378}