Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homework02 Плешнев Арсений 467106 К24 1.2 #150

Closed

Conversation

opensource-lover
Copy link

No description provided.

@anastasiiaCher
Copy link
Owner

В качестве защиты нужно сделать ревью этой лабораторной - #241
Сделать ревью можно во вкладе files changed указанного пул-реквеста

@anastasiiaCher
Copy link
Owner

Ревью работы коллеги хорошее

digits = [c for c in puzzle if c in "123456789."]
grid = group(digits, 9)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Наблюдается использование двух имен (grid и ngrid) для одной и той же логики. Это создает путаницу.



def get_block(grid: tp.List[tp.List[str]], pos: tp.Tuple[int, int]) -> tp.List[str]:
def get_block(ngrid: tp.List[tp.List[str]], pos: tp.Tuple[int, int]) -> tp.List[str]:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_block можно оптимизировать, используя срезы.

['2', '8', '.', '.', '.', '5', '.', '7', '9']
"""
pass

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

почти в каждой функции присутствует pass, хотя фактически он не нужен



def find_empty_positions(grid: tp.List[tp.List[str]]) -> tp.Optional[tp.Tuple[int, int]]:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

find_empty_positions: Вместо магического значения (1000, 1000) лучше возвращать None, если пустых клеток нет

Copy link
Owner

@anastasiiaCher anastasiiaCher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Если внесете правки к 28 января, баллов хватит, чтобы закрыться

Comment on lines +48 to +55
length = len(values)

newls: tp.List[tp.List[T]] = [[] for _ in range(length // n)]

for index, i in enumerate(values):
newls[index // n].append(i)

return newls
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Функция будет более читаемой, если оформите ее в виде спискового включения

Comment on lines +80 to +82
newls = [ngrid[i][pos[1]] for i in range(len(ngrid))]

return newls
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно сразу так return [ngrid[i][pos[1]] for i in range(len(ngrid))]

Comment on lines +161 to +163
values = find_possible_values(ngrid, pos)
if values == None:
return None
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше:

if not values:
    return None

Comment on lines +168 to +170
g = solve(ngrid)

if g == None:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше:

if not solve(ngrid):
    ...

Comment on lines +191 to +194
if row.count(n) == 1 and col.count(n) == 1 and block.count(n) == 1:
continue
else:
return False
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше заменить на сокращенный условный оператор и обойтись без continue

Comment on lines +199 to +200
# def random_gen():
# grid = [["." for _ in range(9)] for _ in range(9)]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лишним комментам не место в коде

Comment on lines +201 to +215


"""
def generate_sudoku(N: int) -> tp.List[tp.List[str]]:
'''Генерация судоку заполненного на N элементов
>>> grid = generate_sudoku(40)
>>> sum(1 for row in grid for e in row if e == '.')
41
>>> solution = solve(grid)
>>> check_solution(solution)
True
>>> grid = generate_sudoku(1000)
>>> sum(1 for row in grid for e in row if e == '.')
0
>>> solution = solve(grid)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это тоже лишний коммент

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

Successfully merging this pull request may close these issues.

3 participants