mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 17:34:49 +08:00
Implemented doctests for geometry-related classes (#12368)
* Implemented doctests for geometry-related classes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Removed unused noqa directive * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * refactored sudoku_solver.py * refactored sudoku_solver.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * context manager for file handling changed too in from_file function --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
This commit is contained in:
@ -23,7 +23,7 @@ unitlist = (
|
||||
+ [cross(rs, cs) for rs in ("ABC", "DEF", "GHI") for cs in ("123", "456", "789")]
|
||||
)
|
||||
units = {s: [u for u in unitlist if s in u] for s in squares}
|
||||
peers = {s: set(sum(units[s], [])) - {s} for s in squares} # noqa: RUF017
|
||||
peers = {s: {x for u in units[s] for x in u} - {s} for s in squares}
|
||||
|
||||
|
||||
def test():
|
||||
@ -172,7 +172,8 @@ def solved(values):
|
||||
|
||||
def from_file(filename, sep="\n"):
|
||||
"Parse a file into a list of strings, separated by sep."
|
||||
return open(filename).read().strip().split(sep)
|
||||
with open(filename) as file:
|
||||
return file.read().strip().split(sep)
|
||||
|
||||
|
||||
def random_puzzle(assignments=17):
|
||||
|
Reference in New Issue
Block a user