timeit

Програмиране с Python

Курс във Факултета по Математика и Информатика към СУ

Черно и бяло

Краен срок
23.03.2016 13:00

Срокът за предаване на решения е отминал

Черно и бяло

За целта на това предизвикателство ще трябва да се поразровите малко и да откриете начин да обърнем нормална картинка до черно-бяла такава (grayscale). Ще очакваме да напишете декоратор grayscale, за функциите rotate_left, rotate_right, invert, darken и lighten от първа задача.

Пример:

Написали сме си rotate_left от първа задача (ако не сте, можете да използвате някое решение на ваш колега, тъй като са вече публични) и изглежда така:

def rotate_left(image):
    return list(zip(*image))[::-1]

Ще използваме отново снимка на една малка панда:

Панда

И ако я подадем на rotate_left използвайки render.py:

python render.py panda.jpg rotate_left

получаваме:

Завъртяна на ляво панда

Ако обаче декорираме rotate_left с @grayscale:

@grayscale
def rotate_left(image):
    return list(zip(*image))[::-1]

резултатът ще бъде:

Завъртяна на ляво черно-бяла панда

Решения

Теодор Тошков
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Теодор Тошков
1
2
3
4
5
6
7
8
9
10
11
12
13
def graypixel(pixel):
    gray = int((pixel[0] + pixel[1] + pixel[2]) / 3)
    return (gray, gray, gray)


def grayimage(image):
    return [[graypixel(pixel) for pixel in row] for row in image]


def grayscale(function):
    def grayscale_inner(*args):
        return grayimage(function(*args))
    return grayscale_inner
....
----------------------------------------------------------------------
Ran 4 tests in 0.052s

OK
Кристина Христакиева
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Кристина Христакиева
1
2
3
4
5
6
7
8
9
10

def grey(pixel): return ((int(sum(pixel) / 3)),) * 3


def grayscale(func):
    def wrapper_func(image, *args):
        new_image = [[grey(pixel) for pixel in row] for row in image]
        return func(new_image, *args)
    return wrapper_func
....
----------------------------------------------------------------------
Ran 4 tests in 0.055s

OK
Николай Желязков
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Николай Желязков
1
2
3
4
5
6
7
8
def grayscale(func):
    def get_grayscale(rgb):
        return (int(0.299 * rgb[0] + 0.587 * rgb[1] + 0.114 * rgb[2]), ) * 3

    def grayscaled(*args):
        image = func(*args)
        return [list(map(get_grayscale, row)) for row in image]
    return grayscaled
....
----------------------------------------------------------------------
Ran 4 tests in 0.052s

OK
Петър Иванов
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Петър Иванов
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from functools import wraps

def grayscale(func):
    @wraps(func)
    def helper(image, *args):
        rows, cols = len(image), len(image[0])
        for i in range(rows):
            for j in range(cols):
                gray = int(sum([x for x in image[i][j]]) / 3)
                image[i][j] = tuple([gray for x in range(3)])
        if len(args) != 0:
            return func(image, args[0])
        return func(image)
    return helper
....
----------------------------------------------------------------------
Ran 4 tests in 0.066s

OK
Тодор Димов
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Тодор Димов
1
2
3
4
5
6
7
8
def grayscale(function):
    def execution(*args):
        def gray(pixel):
            red, green, blue = pixel
            gray = int(0.2989 * red + 0.5870 * green + 0.1140 * blue)
            return (gray, gray, gray)
        return [[gray(pixel) for pixel in row] for row in function(*args)]
    return execution
....
----------------------------------------------------------------------
Ran 4 tests in 0.052s

OK
Георги Данков
  • Некоректно
  • 0 успешни тест(а)
  • 4 неуспешни тест(а)
Георги Данков
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
def grey_out_pixel(pixel):
    red = pixel[0]
    green = pixel[1]
    blue = pixel[2]

    grey = int(red * 0.2126 + green * 0.7152 + blue * 0.0722)
    return (grey, grey, grey)


def greyscale(func):
    def to_greyscale(*arguments):
        picture = arguments[0]
        greyed_out_picture = [[grey_out_pixel(pixel) for pixel in row]
                              for row in picture]

        if len(arguments) == 1:
            return func(greyed_out_picture)
        else:
            coef = arguments[1]
            return func(greyed_out_picture, coef)

    return to_greyscale
EEEE
======================================================================
ERROR: test_grayscale_darken (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AttributeError: module 'solution' has no attribute 'grayscale'

======================================================================
ERROR: test_grayscale_invert (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AttributeError: module 'solution' has no attribute 'grayscale'

======================================================================
ERROR: test_grayscale_lighten (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AttributeError: module 'solution' has no attribute 'grayscale'

======================================================================
ERROR: test_grayscale_rotate_left (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AttributeError: module 'solution' has no attribute 'grayscale'

----------------------------------------------------------------------
Ran 4 tests in 0.052s

FAILED (errors=4)
Данислав Киров
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Данислав Киров
1
2
3
4
5
6
7
8
def grayscale(func):
    def gray(pixel):
        return (int(0.2126*pixel[0] + 0.7152*pixel[1] + 0.0722*pixel[2]), ) * 3

    def make_gray(image, *args):
        return func([[gray(pixel) for pixel in row] for row in image], *args)

    return make_gray
....
----------------------------------------------------------------------
Ran 4 tests in 0.052s

OK
Мартин Терзийски
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Мартин Терзийски
1
2
3
4
5
6
7
8
9
def grayscale(func):
    def mk_gray_pix(pixel):
        r, g, b = pixel
        val = int((r + g + b)/3)
        return (val, val, val)

    def mk_gray_img(*args):
        return [[mk_gray_pix(pixel) for pixel in xs] for xs in func(*args)]
    return mk_gray_img
....
----------------------------------------------------------------------
Ran 4 tests in 0.052s

OK
Илия Жечев
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Илия Жечев
1
2
3
def grayscale(func):
    return lambda *args: [[(round(sum(p) / 3),) * 3 for p in row]
                          for row in func(*args)]
....
----------------------------------------------------------------------
Ran 4 tests in 0.052s

OK
Борис Алтънов
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Борис Алтънов
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
def gray_pixel(pixel):
    gray_pixel = int(0.299 * pixel[0] + 0.587 * pixel[1] + 0.114 * pixel[2])
    pixel = (gray_pixel, gray_pixel, gray_pixel)
    return pixel


def grayscale(func):
    def gray_image(*args):
        gray_image = [[gray_pixel((args[0][row][col]))
                       for col in range(len((args[0][0])))]
                      for row in range(len((args[0])))]
        if len(args) == 1:
            return func(gray_image)
        else:
            return func(gray_image, args[1])
    return gray_image
....
----------------------------------------------------------------------
Ran 4 tests in 0.052s

OK
Тина Накова
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Тина Накова
1
2
3
4
5
6
7
8
9
10
def grayscale(func):
    def create_grayscale_image(image, *args):
        width = range(len(image[0]))
        grayscale_image = [[tuple(3*(int((row[col][0] +
                                          row[col][1] +
                                          row[col][2])/3),))
                            for col in width] for row in image]

        return func(grayscale_image, *args)
    return create_grayscale_image
....
----------------------------------------------------------------------
Ran 4 tests in 0.052s

OK
Ивета Чампоева
  • Некоректно
  • 0 успешни тест(а)
  • 4 неуспешни тест(а)
Ивета Чампоева
1
2
3
4
5
6
7
8
9
def grayscale(func):
    def make_grayscale(image, *args):
        def made_grayscale(image):
            def get_level(r, g, b):
                return int(r*0.21 + g*0.71 + b*0.07)
            return [[(get_level(x, y, z), get_level(x, y, z),
                      get_level(x, y, x)) for x, y, z in row] for row in image]
        return func(made_grayscale(image), *args)
    return make_grayscale
FFFF
======================================================================
FAIL: test_grayscale_darken (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AssertionError: 8 != 0

======================================================================
FAIL: test_grayscale_invert (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AssertionError: 238 != 255

======================================================================
FAIL: test_grayscale_lighten (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AssertionError: 136 != 127

======================================================================
FAIL: test_grayscale_rotate_left (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AssertionError: 17 != 0

----------------------------------------------------------------------
Ran 4 tests in 0.056s

FAILED (failures=4)
Алекс Николов
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Алекс Николов
1
2
3
4
5
6
7
8
9
10
11
12
13
def grayscale_pixel(pixel):
    average = int((pixel[0] + pixel[1] + pixel[2]) / 3)
    return (average, average, average)


def grayscale(func):
    def grayscaled(*args):
        altered_image = func(*args)
        height = len(altered_image)
        width = len(altered_image[0])
        return [[grayscale_pixel(altered_image[row][col])
                for col in range(width)] for row in range(height)]
    return grayscaled
....
----------------------------------------------------------------------
Ran 4 tests in 0.059s

OK
Бисер Кръстев
  • Некоректно
  • 0 успешни тест(а)
  • 4 неуспешни тест(а)
Бисер Кръстев
1
2
3
4
5
6
7
8
def grayscale():
    def pixel(r, g, b):
        return (r*0.2126 + g*0.7152 + b*0.0722,)*3

    def result_function(image):
        return [[pixel(r, g, b) for (r, g, b) in row] for row in image]

    return result_function
EEEE
======================================================================
ERROR: test_grayscale_darken (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: grayscale() takes 0 positional arguments but 1 was given

======================================================================
ERROR: test_grayscale_invert (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: grayscale() takes 0 positional arguments but 1 was given

======================================================================
ERROR: test_grayscale_lighten (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: grayscale() takes 0 positional arguments but 1 was given

======================================================================
ERROR: test_grayscale_rotate_left (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: grayscale() takes 0 positional arguments but 1 was given

----------------------------------------------------------------------
Ran 4 tests in 0.053s

FAILED (errors=4)
Десислава Цветкова
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Десислава Цветкова
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# The commented is anoter solution - another 'type' of gray
# VALS = [0.2126, 0.7152, 0.0722]


def grayscale(func):
    def decorated_func(*args):
        return make_gray(func(*args))
    return decorated_func


def make_gray_pixel(pix):
    c_lin = int(sum(pix) / 3)
    # c_lin = int(sum([a * b for a, b in zip(VALS, pix)]))
    return (c_lin, c_lin, c_lin)


def make_gray(image):
    return [[make_gray_pixel(image[i][j]) for j
             in range(len(image[0]))] for i in range(len(image))]
....
----------------------------------------------------------------------
Ran 4 tests in 0.052s

OK
Кристофър Митов
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Кристофър Митов
1
2
3
4
5
6
7
8
def grayscale(function):
    def map_function(pixel):
        grayed_color = sum(pixel)//3
        return (grayed_color, grayed_color, grayed_color)

    def inner(*args):
        return [list(map(map_function, row)) for row in function(*args)]
    return inner
....
----------------------------------------------------------------------
Ran 4 tests in 0.052s

OK
Даниел Делчев
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Даниел Делчев
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
def grayscale(func):
    def negative_pixel(pixel):
        red = pixel[0]
        green = pixel[1]
        blue = pixel[2]
        intensity = (red + green + blue) / 3
        return int(intensity), int(intensity), int(intensity)

    def negative_line(matrix_line):
        length = len(matrix_line)
        return [negative_pixel(matrix_line[x]) for x in range(0, length)]

    def negative_matrix(matrix):
        length = len(matrix)
        return [negative_line(matrix[x]) for x in range(0, length)]

    def grayscaled(*args, **kwargs):
        return negative_matrix(func(*args, **kwargs))

    return grayscaled
....
----------------------------------------------------------------------
Ran 4 tests in 0.052s

OK
Николай Бабулков
  • Некоректно
  • 0 успешни тест(а)
  • 4 неуспешни тест(а)
Николай Бабулков
1
2
3
4
5
6
7
8
9
10
11
def pixel_gray(pixel):
    color = int(0.21*pixel[0] + 0.72*pixel[1] + 0.07*pixel[2])
    return (color,)*3


def greyscale(function):
    def greyscaled(*args):
        image = [[pixel_gray(pixel) for pixel in row] for row in args[0]]
        func_args = (image,) + args[1:]
        return function(*func_args)
    return greyscaled
EEEE
======================================================================
ERROR: test_grayscale_darken (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AttributeError: module 'solution' has no attribute 'grayscale'

======================================================================
ERROR: test_grayscale_invert (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AttributeError: module 'solution' has no attribute 'grayscale'

======================================================================
ERROR: test_grayscale_lighten (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AttributeError: module 'solution' has no attribute 'grayscale'

======================================================================
ERROR: test_grayscale_rotate_left (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AttributeError: module 'solution' has no attribute 'grayscale'

----------------------------------------------------------------------
Ran 4 tests in 0.052s

FAILED (errors=4)
Йоан Динков
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Йоан Динков
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
def grayscale(f):
    def grayed(*args, **kwargs):
        return gray_convertion(f(*args, **kwargs))
    return grayed


def gray_convertion(image):
    result = [row[:] for row in image]

    for row in range(len(result)):
        if result[row]:
            for column in range(len(result[row])):
                gray = int(sum((image[row][column])) / 3)

                result[row][column] = (gray, gray, gray)

    return result
...E
======================================================================
ERROR: test_grayscale_rotate_left (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: 'tuple' object does not support item assignment

----------------------------------------------------------------------
Ran 4 tests in 0.052s

FAILED (errors=1)
Денис Михайлов
  • Некоректно
  • 2 успешни тест(а)
  • 2 неуспешни тест(а)
Денис Михайлов
1
2
3
4
5
6
7
8
9
10
11
12
13
def grayscale(function):
    def grayscale_pixel(pixel):
        red = int(0.299 * pixel[0])
        green = int(0.587 * pixel[1])
        blue = int(0.114 * pixel[2])
        gray = red + green + blue
        return (gray, gray, gray)

    def decorator(picture):
        new_picture = function(picture)
        return [list(map(grayscale_pixel, row)) for row in new_picture]

    return decorator
E.E.
======================================================================
ERROR: test_grayscale_darken (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: decorator() takes 1 positional argument but 2 were given

======================================================================
ERROR: test_grayscale_lighten (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: decorator() takes 1 positional argument but 2 were given

----------------------------------------------------------------------
Ran 4 tests in 0.053s

FAILED (errors=2)
Андрей Иванов
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Андрей Иванов
1
2
3
4
5
6
7
8
9
10
def to_gray(pixel):
    average = int((pixel[0] + pixel[1] + pixel[2])/3)
    return (average, average, average)


def grayscale(function):
    def f(image, *number):
        grayscale_image = [[to_gray(pixel) for pixel in row] for row in image]
        return function(grayscale_image, *number)
    return f
....
----------------------------------------------------------------------
Ran 4 tests in 0.052s

OK
Александрина Ламбова
  • Некоректно
  • 2 успешни тест(а)
  • 2 неуспешни тест(а)
Александрина Ламбова
1
2
3
4
5
6
7
8
9
def grayscale(function):
    def make_grey_pixel(R, G, B):
        new_color = round(0.21 * R + 0.72 * G + 0.07 * B, 3)
        return (new_color, new_color, new_color)

    def make_grey(image_row):
        return [make_grey_pixel(R, G, B) for R, G, B in image_row]

    return (lambda x: list(map(make_grey, function(x))))
E.E.
======================================================================
ERROR: test_grayscale_darken (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: <lambda>() takes 1 positional argument but 2 were given

======================================================================
ERROR: test_grayscale_lighten (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: <lambda>() takes 1 positional argument but 2 were given

----------------------------------------------------------------------
Ran 4 tests in 0.059s

FAILED (errors=2)
Георги Иванов
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Георги Иванов
1
2
3
4
5
6
7
8
9
10
11
12
13
def grayscale_pixel(pixel):
    average = int((pixel[0] + pixel[1] + pixel[2]) / 3)
    return (average, average, average)


def grayscale(func):
    def wrapper(*args):
        grayscaled = [[grayscale_pixel(pixel)
                       for pixel in row] for row in args[0]]
        if len(args) == 2:
            return func(grayscaled, args[1])
        return func(grayscaled)
    return wrapper
....
----------------------------------------------------------------------
Ran 4 tests in 0.052s

OK
Николай Лазаров
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Николай Лазаров
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
def transform(pixel):
    # grayscale_value = int((pixel[0]+pixel[1]+pixel[2])/3)
    grayscale_value = int(
        0.2989*pixel[0] + 0.5870*pixel[1] + 0.1140*pixel[2]
    )
    return (grayscale_value, grayscale_value, grayscale_value)


def grayscale(func):
    def inner(*args):
        new_args = (
            [[transform(pixel) for pixel in row] for row in args[0]],
            *args[1:]
        )
        return func(*new_args)

    return inner
....
----------------------------------------------------------------------
Ran 4 tests in 0.052s

OK
Славена Теодосиева
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Славена Теодосиева
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
def grayscale(image_functions):
    def turn_into_grayscale(image, *args):
        new_image = list(list((int((image[row][column][0] +
                                    image[row][column][1] +
                                    image[row][column][2]) / 3),
                               int((image[row][column][0] +
                                    image[row][column][1] +
                                    image[row][column][2]) / 3),
                               int((image[row][column][0] +
                                    image[row][column][1] +
                                    image[row][column][2]) / 3))
                    for column in range(len(image[0])))
                for row in range(len(image)))
        return image_functions(new_image, *args)
    return turn_into_grayscale
....
----------------------------------------------------------------------
Ran 4 tests in 0.052s

OK
Виктор Маринов
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Виктор Маринов
1
2
3
4
5
6
7
8
9
10
11
12
13
14
def grayscaled_pixel(pixel):
    r, g, b = pixel
    avg = int((r + g + b) / 3)
    return (avg, avg, avg)


def grayscaled_image(image):
    return [[grayscaled_pixel(pixel) for pixel in row] for row in image]


def grayscale(func):
    def wrapper(*args):
        return func(grayscaled_image(args[0]), *args[1:])
    return wrapper
....
----------------------------------------------------------------------
Ran 4 tests in 0.052s

OK
Веселин Иванов
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Веселин Иванов
1
2
3
4
5
6
7
8
9
10
def grayscale(func):
    def grayscale_pixel(pixel):
        gray = int(0.2989 * pixel[0] + 0.5870 * pixel[1] + 0.1140 * pixel[2])
        return (gray, gray, gray)

    def grayscale_image(image, *args):
        return func([[grayscale_pixel(pixel) for pixel in row]
                    for row in image], *args)

    return grayscale_image
....
----------------------------------------------------------------------
Ran 4 tests in 0.052s

OK
Николай Мантаров
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Николай Мантаров
1
2
3
4
5
6
7
8
9
10
def grayscale(func):
    def convert(pixel):
        gray_color = int((pixel[0] + pixel[1] + pixel[2]) / 3)
        return (gray_color, gray_color, gray_color)

    def grayscaled(image, *scale):
        result = func(image, *scale)
        new_image = [[convert(pixel) for pixel in row] for row in result]
        return new_image
    return grayscaled
....
----------------------------------------------------------------------
Ran 4 tests in 0.052s

OK
Емануил Антонов
  • Некоректно
  • 2 успешни тест(а)
  • 2 неуспешни тест(а)
Емануил Антонов
1
2
3
4
5
6
7
8
9
10
from collections import Counter

def grayscale(f):
    def helper(image):
        self=f(image)
        return [list(map(lambda x: (int((x[0]+x[1]+x[2])/3), 
                                    int((x[0]+x[1]+x[2])/3), 
                                    int((x[0]+x[1]+x[2])/3)), row))
                                    for row in self]
    return helper
E.E.
======================================================================
ERROR: test_grayscale_darken (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: helper() takes 1 positional argument but 2 were given

======================================================================
ERROR: test_grayscale_lighten (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: helper() takes 1 positional argument but 2 were given

----------------------------------------------------------------------
Ran 4 tests in 0.052s

FAILED (errors=2)
Марина Георгиева
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Марина Георгиева
1
2
3
4
5
6
7
8
9
10
11
12
def grayscale(function):
    def grayscaled(*args):
        image = args[0]
        for row in range(len(image)):
            for col in range(len(image[row])):
                pixel = list(image[row][col])
                grey = int((pixel[0] + pixel[1] + pixel[2]) / 3)
                for i in range(len(image[row][col])):
                    pixel[i] = grey
                image[row][col] = tuple(pixel)
        return function(*args)
    return grayscaled
....
----------------------------------------------------------------------
Ran 4 tests in 0.052s

OK
Емил Илиев
  • Некоректно
  • 2 успешни тест(а)
  • 2 неуспешни тест(а)
Емил Илиев
1
2
3
4
5
6
7
8
9
10
def gray_pixel(pixel):
    pix = int((pixel[0] + pixel[1] + pixel[2]) / 3)
    return (pix, pix, pix)


def grayscale(function):
    def convert_grayscale(image):
        new_img = [[gray_pixel(pixel) for pixel in row] for row in image]
        return function(new_img)
    return convert_grayscale
E.E.
======================================================================
ERROR: test_grayscale_darken (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: convert_grayscale() takes 1 positional argument but 2 were given

======================================================================
ERROR: test_grayscale_lighten (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: convert_grayscale() takes 1 positional argument but 2 were given

----------------------------------------------------------------------
Ran 4 tests in 0.053s

FAILED (errors=2)
Даниел Шушков
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Даниел Шушков
1
2
3
4
5
6
7
8
9
def grayscale(function):
    def grayscale_func(*args):
        return [list(map(
            lambda x:
            (int(0.2989 * x[0] + 0.5870 * x[1] + 0.1140 * x[2]),
             int(0.2989 * x[0] + 0.5870 * x[1] + 0.1140 * x[2]),
             int(0.2989 * x[0] + 0.5870 * x[1] + 0.1140 * x[2])), row))
            for row in function(*args)]
    return grayscale_func
....
----------------------------------------------------------------------
Ran 4 tests in 0.052s

OK
Хризантема Станчева
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Хризантема Станчева
1
2
3
4
5
6
7
8
9
10
11
12
13
14
def grayscale_pixel(pixel):
    tmp = int(0.2126 * pixel[0] + 0.7152 * pixel[1] + 0.0722 * pixel[2])
    return (tmp, tmp, tmp)


def grayscale_image(image):
    return [[grayscale_pixel(pixel) for pixel in row] for row in image]


def grayscale(function):
    def decorator(*args, **kwargs):
        current_image = function(*args, **kwargs)
        return grayscale_image(current_image)
    return decorator
....
----------------------------------------------------------------------
Ran 4 tests in 0.052s

OK
Божидар Карааргиров
  • Некоректно
  • 0 успешни тест(а)
  • 4 неуспешни тест(а)
Божидар Карааргиров
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
def grayscale(function):
    def make_grayscale_image(*args, **kwargs):
        def apply_grayscale(pixel):
            intensity = round(0.2989 * pixel[0] +
                              0.5870 * pixel[1] +
                              0.1140 * pixel[2])
            return intensity, intensity, intensity

        new_args = []
        for index in range(0, len(args)):
            if index is 0:[list(map(apply_grayscale, row))
                                 for row in args[0]]
            else:
                new_args.append(args[index])

        return function(*new_args, **kwargs)
    return make_grayscale_image
EEEE
======================================================================
ERROR: test_grayscale_darken (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: darken() missing 1 required positional argument: 'percent'

======================================================================
ERROR: test_grayscale_invert (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: invert() missing 1 required positional argument: 'image'

======================================================================
ERROR: test_grayscale_lighten (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: lighten() missing 1 required positional argument: 'percent'

======================================================================
ERROR: test_grayscale_rotate_left (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: rotate_left() missing 1 required positional argument: 'image'

----------------------------------------------------------------------
Ran 4 tests in 0.053s

FAILED (errors=4)
Яница Велевска
  • Некоректно
  • 0 успешни тест(а)
  • 4 неуспешни тест(а)
Яница Велевска
1
2
3
4
5
6
7
def gray_scale_pixel(pixel):
    i = int((pixel[0] + pixel[1] + pixel[2])/3)
    return (i,i,i)
def gray_scale(funk):
    def inner_funk(img):
        return funk([[gray_scale_pixel(pixel) for pixel in row] for row in img])
    return inner_funk
EEEE
======================================================================
ERROR: test_grayscale_darken (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AttributeError: module 'solution' has no attribute 'grayscale'

======================================================================
ERROR: test_grayscale_invert (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AttributeError: module 'solution' has no attribute 'grayscale'

======================================================================
ERROR: test_grayscale_lighten (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AttributeError: module 'solution' has no attribute 'grayscale'

======================================================================
ERROR: test_grayscale_rotate_left (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AttributeError: module 'solution' has no attribute 'grayscale'

----------------------------------------------------------------------
Ran 4 tests in 0.677s

FAILED (errors=4)
Димо Дрънгов
  • Некоректно
  • 0 успешни тест(а)
  • 4 неуспешни тест(а)
Димо Дрънгов
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
from collections import defaultdict


def column(matrix, n):
    return [l[n] for l in matrix]


def rev(l):
    return [l[i] for i in range(len(l) - 1, -1, -1)]


def greyscale_pixel(pixel):
    average = (int)((pixel[0]+pixel[1]+pixel[2])/3)
    return (average, average, average)


def greyscale_img(img):
    return [[greyscale_pixel(img[i][j]) for j in range(len(img[0]))]
            for i in range(len(img))]


def greyscale(func):
    def gr_sc(img, *a):
        image = func(img, *a)
        return greyscale_img(image)
    return gr_sc


@greyscale
def rotate_left(img):
    return [column(img, i) for i in range(len(img[0]) - 1, -1, -1)]


@greyscale
def rotate_right(img):
    return[rev(column(img, i)) for i in range(0, len(img[0]))]


def invert_color(col):
    return (int)(255-col)


def invert_pixel(pixel):
    return tuple(invert_color(pixel[i]) for i in range(len(pixel)))


@greyscale
def invert(img):
    return [[invert_pixel(img[i][j])
             for j in range(len(img[0]))] for i in range(len(img))]


def proc_pixel(func):
    def process(pixel, coef):
        return tuple(func(pixel[i], coef) for i in range(len(pixel)))
    return process


def proc_img(func):
    def image(img, coef):
        return [[func(img[i][j], coef) for j in range(len(img[0]))]
                for i in range(len(img))]
    return image


@greyscale
@proc_img
@proc_pixel
def lighten(col, coef):
    return (int)(col + coef*(255-col))


@greyscale
@proc_img
@proc_pixel
def darken(col, coef):
    return (int)(col - coef*(col - 0))


def create_histogram(img):
    result = {'red': defaultdict(int),
              'green': defaultdict(int),
              'blue': defaultdict(int)}
    h = len(img)
    w = len(img[0])
    for i in range(h):
        for j in range(w):
            result['red'][img[i][j][0]] += 1
            result['green'][img[i][j][1]] += 1
            result['blue'][img[i][j][2]] += 1
    return result
EEEE
======================================================================
ERROR: test_grayscale_darken (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AttributeError: module 'solution' has no attribute 'grayscale'

======================================================================
ERROR: test_grayscale_invert (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AttributeError: module 'solution' has no attribute 'grayscale'

======================================================================
ERROR: test_grayscale_lighten (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AttributeError: module 'solution' has no attribute 'grayscale'

======================================================================
ERROR: test_grayscale_rotate_left (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AttributeError: module 'solution' has no attribute 'grayscale'

----------------------------------------------------------------------
Ran 4 tests in 0.052s

FAILED (errors=4)
Светомир Стоименов
  • Некоректно
  • 0 успешни тест(а)
  • 4 неуспешни тест(а)
Светомир Стоименов
1
2
3
4
5
6
7
8
9
def grey_pixel(pixel):
    return (int(pixel[0] * 0.3 + pixel[1] * 0.59 + pixel[2] * 0.11),) * 3


def greyscale(func):
    def greyscaled(image, *args):
        new_image = func(image, *args)
        return [[grey_pixel(pixel) for pixel in row] for row in new_image]
    return greyscaled
EEEE
======================================================================
ERROR: test_grayscale_darken (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AttributeError: module 'solution' has no attribute 'grayscale'

======================================================================
ERROR: test_grayscale_invert (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AttributeError: module 'solution' has no attribute 'grayscale'

======================================================================
ERROR: test_grayscale_lighten (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AttributeError: module 'solution' has no attribute 'grayscale'

======================================================================
ERROR: test_grayscale_rotate_left (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AttributeError: module 'solution' has no attribute 'grayscale'

----------------------------------------------------------------------
Ran 4 tests in 0.052s

FAILED (errors=4)
Галин Ангелов
  • Некоректно
  • 0 успешни тест(а)
  • 4 неуспешни тест(а)
Галин Ангелов
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from itertools import chain
from collections import Counter

# Used Alexander Nadjarian implementations


def grayscale(func):
    def inner(*args, **kwargs):
        image = func(*args, **kwargs)
        newImage = []
        for row in range(0, len(image)):
            line = []
            for col in range(0, len(image[row])):
                grey = (col[0]+col[1]+col[2])/3
                pixel = (grey, grey, grey)
                line.append(pixel)
            newImage.append(line)
        return newImage
    return inner


@grayscale
def rotate_left(image):
    iteration = range(len(image[0])-1, -1, -1)
    return [[row[column] for row in image] for column in iteration]


@grayscale
def rotate_right(image):
    iteration = range(len(image[0]))
    return [[row[column] for row in image[::-1]] for column in iteration]


@grayscale
def invert(image):
    return [[(255-r, 255-g, 255-b) for r, g, b in row] for row in image]


def lighten_(pixel, alpha):
    return tuple(map(lambda x: int(x + alpha*(255 - x)), pixel))


@grayscale
def lighten(image, alpha):
    return [[lighten_(pixel, alpha) for pixel in row] for row in image]


def darken_(pixel, alpha):
    return tuple(map(lambda x: int(x - alpha*x), pixel))


@grayscale
def darken(image, alpha):
    return [[darken_(pixel, alpha) for pixel in row] for row in image]
EEEE
======================================================================
ERROR: test_grayscale_darken (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: 'int' object is not subscriptable

======================================================================
ERROR: test_grayscale_invert (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: 'int' object is not subscriptable

======================================================================
ERROR: test_grayscale_lighten (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: 'int' object is not subscriptable

======================================================================
ERROR: test_grayscale_rotate_left (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: 'int' object is not subscriptable

----------------------------------------------------------------------
Ran 4 tests in 0.053s

FAILED (errors=4)
Марианна Владимирова
  • Некоректно
  • 0 успешни тест(а)
  • 4 неуспешни тест(а)
Марианна Владимирова
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
def greyscale(func):
    def greyscaled(*args):
        row_length = len(args[0])
        for row in args[0]:
            for index in range(row_length):
                row[index] = weightedAverage(row[index])
        return func(*args)
    return greyscaled


def weightedAverage(pixel):
    red, green, blue = pixel
    luminance = int(red * 0.299) + int(green * 0.587) + int(blue * 0.114)
    pixel = luminance, luminance, luminance
    return pixel
EEEE
======================================================================
ERROR: test_grayscale_darken (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AttributeError: module 'solution' has no attribute 'grayscale'

======================================================================
ERROR: test_grayscale_invert (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AttributeError: module 'solution' has no attribute 'grayscale'

======================================================================
ERROR: test_grayscale_lighten (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AttributeError: module 'solution' has no attribute 'grayscale'

======================================================================
ERROR: test_grayscale_rotate_left (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AttributeError: module 'solution' has no attribute 'grayscale'

----------------------------------------------------------------------
Ran 4 tests in 0.052s

FAILED (errors=4)
Стилиян Стоянов
  • Некоректно
  • 0 успешни тест(а)
  • 4 неуспешни тест(а)
Стилиян Стоянов
1
2
3
4
5
6
7
8
9
10
def grayscale(func):
    def rgb_to_gray(pixel):
        grayscaled = int((pixel[0] + pixel[1] + pixel[2])/3)
        return tuple((grayscaled, grayscaled, grayscaled))

    def grayscaled_image(*args):
        image, new_image = func(*args), []
        [[rgb_to_gray(pixel) for pixel in row] for row in image]
        return new_image
    return grayscaled_image
FFFF
======================================================================
FAIL: test_grayscale_darken (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AssertionError: 3 != 0

======================================================================
FAIL: test_grayscale_invert (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AssertionError: 3 != 0

======================================================================
FAIL: test_grayscale_lighten (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AssertionError: 3 != 0

======================================================================
FAIL: test_grayscale_rotate_left (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AssertionError: 3 != 0

----------------------------------------------------------------------
Ran 4 tests in 0.054s

FAILED (failures=4)
Ивелин Тодоров
  • Некоректно
  • 0 успешни тест(а)
  • 4 неуспешни тест(а)
Ивелин Тодоров
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from functools import wraps


def greyscale(func):
    @wraps(func)
    def wrapper(matrix):
        res = func(matrix)
        for row in res:
            for ind, pix in enumerate(row):
                greysc = sum(pix) / len(pix)
                new_pix = tuple([int(greysc) for i in range(len(pix))])
                row[ind] = new_pix
        return res
    return wrapper
EEEE
======================================================================
ERROR: test_grayscale_darken (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AttributeError: module 'solution' has no attribute 'grayscale'

======================================================================
ERROR: test_grayscale_invert (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AttributeError: module 'solution' has no attribute 'grayscale'

======================================================================
ERROR: test_grayscale_lighten (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AttributeError: module 'solution' has no attribute 'grayscale'

======================================================================
ERROR: test_grayscale_rotate_left (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
AttributeError: module 'solution' has no attribute 'grayscale'

----------------------------------------------------------------------
Ran 4 tests in 0.060s

FAILED (errors=4)
Симеон Ролев
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Симеон Ролев
1
2
3
4
5
6
7
8
9
10
11
12
13
14
def grayscale(func):
    def insideFunc(image, *args):
        new_image = []
        for row in image:
            new_row = []
            for pixel in row:
                new_pixel = (
                    int((pixel[0] + pixel[1] + pixel[2]) / 3),
                    int((pixel[0] + pixel[1] + pixel[2]) / 3),
                    int((pixel[0] + pixel[1] + pixel[2]) / 3))
                new_row.append(new_pixel)
            new_image.append(new_row)
        return func(new_image, *args)
    return insideFunc
....
----------------------------------------------------------------------
Ran 4 tests in 0.052s

OK
Марио Даскалов
  • Некоректно
  • 2 успешни тест(а)
  • 2 неуспешни тест(а)
Марио Даскалов
1
2
3
4
5
6
7
8
9
10
def grayscale(function):
    def grayscale_rgb(pixel):
        luminosity = int(0.21 * pixel[0] + 0.72 * pixel[1] + 0.07 * pixel[2])
        return (luminosity, luminosity, luminosity)

    def grayscale_transformation(picture):
        transformed_picture = function(picture)
        return [list(map(grayscale_rgb, row)) for row in transformed_picture]

    return grayscale_transformation
E.E.
======================================================================
ERROR: test_grayscale_darken (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: grayscale_transformation() takes 1 positional argument but 2 were given

======================================================================
ERROR: test_grayscale_lighten (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: grayscale_transformation() takes 1 positional argument but 2 were given

----------------------------------------------------------------------
Ran 4 tests in 0.061s

FAILED (errors=2)
Александър Наджарян
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Александър Наджарян
1
2
3
4
5
6
7
8
9
10
def to_gray(red, green, blue):
    gray = int(0.3*red) + int(0.59*green) + int(0.11*blue)
    return (gray, gray, gray)


def grayscale(f):
    def decorate(*args, **kwargs):
        image = f(*args, **kwargs)
        return [[to_gray(*pixel) for pixel in row] for row in image]
    return decorate
....
----------------------------------------------------------------------
Ran 4 tests in 0.052s

OK
Любослава Димитрова
  • Некоректно
  • 2 успешни тест(а)
  • 2 неуспешни тест(а)
Любослава Димитрова
1
2
3
4
5
6
7
8
9
10
11
12
def grayscale(func):
    def convert(image):
        converted = func(image)
        result = []
        for row in converted:
            new_row = []
            for pixel in row:
                average = int(sum(pixel)/3)
                new_row.append((average, average, average))
            result.append(new_row)
        return result
    return convert
E.E.
======================================================================
ERROR: test_grayscale_darken (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: convert() takes 1 positional argument but 2 were given

======================================================================
ERROR: test_grayscale_lighten (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: convert() takes 1 positional argument but 2 were given

----------------------------------------------------------------------
Ran 4 tests in 0.060s

FAILED (errors=2)
Христо Ралев
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Христо Ралев
1
2
3
4
5
6
7
8
9
10
11
def grayscale_formula(r,g,b):
        return int(r * 0.2126 + g * 0.7152 + b * 0.0722)

def grayscale(func):
    def wrapper(image, *n):
        return [[(grayscale_formula(r,g,b),
                  grayscale_formula(r,g,b),
                  grayscale_formula(r,g,b))
         for (r, g, b) in row] for row in func(image, *n)]
    return wrapper
....
----------------------------------------------------------------------
Ran 4 tests in 0.065s

OK
Димитър Керезов
  • Некоректно
  • 2 успешни тест(а)
  • 2 неуспешни тест(а)
Димитър Керезов
1
2
3
4
5
6
7
8
9
10
11
12
13
def grayscale(func):
    def grey_out(rgb):
        grey = (int)((rgb[0] + rgb[1] + rgb[2])/3)
        return grey, grey, grey


    def grey_out_line(line):
        return list(map(grey_out, line))


    def grayscale_wrapper(image):
        return func(list(map(grey_out_line, image)))
    return grayscale_wrapper
E.E.
======================================================================
ERROR: test_grayscale_darken (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: grayscale_wrapper() takes 1 positional argument but 2 were given

======================================================================
ERROR: test_grayscale_lighten (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: grayscale_wrapper() takes 1 positional argument but 2 were given

----------------------------------------------------------------------
Ran 4 tests in 0.053s

FAILED (errors=2)
Христо Владев
  • Некоректно
  • 0 успешни тест(а)
  • 4 неуспешни тест(а)
Христо Владев
1
2
3
4
def grayscale(image):
    return [
        [(0.21 * r + 0.72 * g + 0.07 * b) for r, g, b in row] for row in image
    ]
EEEE
======================================================================
ERROR: test_grayscale_darken (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: 'function' object is not iterable

======================================================================
ERROR: test_grayscale_invert (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: 'function' object is not iterable

======================================================================
ERROR: test_grayscale_lighten (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: 'function' object is not iterable

======================================================================
ERROR: test_grayscale_rotate_left (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: 'function' object is not iterable

----------------------------------------------------------------------
Ran 4 tests in 0.052s

FAILED (errors=4)
Явор Михайлов
  • Некоректно
  • 2 успешни тест(а)
  • 2 неуспешни тест(а)
Явор Михайлов
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
def transponse_image(image):
     return ([list(x) for x in zip(*image)])

def grayscale(some_function):
        def wrapper(image):
                grayscale_image = []

                for row in image:
                    grayscale_image.append([
                        (
                            (x + y + z / 3),
                            (x + y + z / 3),
                            (x + y + z / 3),
                        ) for x, y, z in row
                    ])

                return grayscale_image

        return wrapper



@grayscale
def rotate_left(image):
    image = transponse_image(image)

    return image[::-1]
E.E.
======================================================================
ERROR: test_grayscale_darken (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: wrapper() takes 1 positional argument but 2 were given

======================================================================
ERROR: test_grayscale_lighten (test.TestImages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/rails/pyfmi-2016/releases/20160307095126/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: wrapper() takes 1 positional argument but 2 were given

----------------------------------------------------------------------
Ran 4 tests in 0.052s

FAILED (errors=2)