Skip to content

Fix testing bug #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

PeganovAnton
Copy link
Contributor

@PeganovAnton PeganovAnton commented Sep 3, 2019

bug-in-task_27-task_7_5
If the rightmost painted cell has to be on the border of the robot pitch
the cell is not painted and task testing system reports an error wrongly.

Если крайняя клетка, которую нужно закрасить, на границе, тестирующая система ее не включает в задание.

If the rightmost painted cell has to be on the border of the robot pitch
the cell is not painted and task testing system reports an error wrongly.
@PeganovAnton
Copy link
Contributor Author

Мое решение к задаче

#!/usr/bin/python3

from pyrob.api import *


def cell_needs_filling(cell_idx, filled_idx):
    return 2 * cell_idx == filled_idx * (filled_idx - 1)


@task
def task_7_5():
    """Consider arithmetic progression with initial term `a_1 = 0`
    and difference `d = 1`. Distance between `n`-th painted cell 
    (counting from one) and first painted cell is equal to 
    sum of first `n` members of the progression. Here the distance
    is the difference between row indices of the painted cells.
    
    Consider a robot passing through `n-1` painted cells and stopping
    exactly before `n`-th painted cell (`n = 1, ...`). 
    Let the `k` be number steps made by the robot (`k = 0, ...`). 
    Than, in consideration of position of the first painted cell, `k` 
    and `n` satisfy the following equation
    `k = n * (n-1) / 2` (follows from formula of sum of first members
    of arithmetic progression).   
    
    """
    cell_idx = 0
    filled_idx = 1
    while not wall_is_on_the_right():
        move_right()
        if cell_needs_filling(cell_idx, filled_idx):
            fill_cell()
            filled_idx += 1
        cell_idx += 1


if __name__ == '__main__':
    run_tasks()

@fufler
Copy link
Contributor

fufler commented Nov 12, 2019

Спасибо за PR. Нужно поправить решение , чтобы сборка проходила корректно.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants