From 3a14936e2fc6e5c9682eee34391265902c30e786 Mon Sep 17 00:00:00 2001 From: Olivia Appleton Date: Mon, 2 Dec 2024 19:21:14 -0600 Subject: [PATCH] Fix language version errors, GA push filters --- .github/workflows/c-lint.yml | 1 + .github/workflows/c.yml | 1 + .github/workflows/codeql.yml | 1 + .github/workflows/cplusplus-lint.yml | 1 + .github/workflows/cplusplus.yml | 1 + .github/workflows/csharp-lint.yml | 1 + .github/workflows/csharp.yml | 1 + .github/workflows/eslint.yml | 1 + .github/workflows/fortran.yml | 1 + .github/workflows/java-lint.yml | 2 + .github/workflows/java.yml | 2 + .github/workflows/javascript.yml | 1 + .github/workflows/lua-cov.yml | 1 + .github/workflows/lua-lint.yml | 1 + .github/workflows/lua.yml | 1 + .github/workflows/pages.yml | 1 + .github/workflows/python-lint.yml | 1 + .github/workflows/python.yml | 1 + .github/workflows/rust-clippy.yml | 1 + .github/workflows/rust.yml | 5 +- python/src/p0096.py | 118 +++++++++++++-------------- 21 files changed, 83 insertions(+), 61 deletions(-) diff --git a/.github/workflows/c-lint.yml b/.github/workflows/c-lint.yml index 540216d6..9a137121 100644 --- a/.github/workflows/c-lint.yml +++ b/.github/workflows/c-lint.yml @@ -5,6 +5,7 @@ on: paths: - 'c/**' - '!c/README.rst' + - '.github/workflows/c-lint.yml' schedule: - cron: "0 0 1 * *" diff --git a/.github/workflows/c.yml b/.github/workflows/c.yml index 691e4e79..5514d713 100644 --- a/.github/workflows/c.yml +++ b/.github/workflows/c.yml @@ -5,6 +5,7 @@ on: paths: - 'c/**' - '!c/README.rst' + - '.github/workflows/c.yml' schedule: - cron: "0 0 1 * *" diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index d1dbf543..e1bc3f59 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -25,6 +25,7 @@ on: - 'javascript/**' - 'python/**' - '!*/README.rst' + - '.github/workflows/codeql.yml' pull_request: schedule: - cron: '29 10 * * 4' diff --git a/.github/workflows/cplusplus-lint.yml b/.github/workflows/cplusplus-lint.yml index 6281e0a9..9fafa701 100644 --- a/.github/workflows/cplusplus-lint.yml +++ b/.github/workflows/cplusplus-lint.yml @@ -5,6 +5,7 @@ on: paths: - 'cplusplus/**' - '!cplusplus/README.rst' + - '.github/workflows/cplusplus-lint.yml' schedule: - cron: "0 0 1 * *" diff --git a/.github/workflows/cplusplus.yml b/.github/workflows/cplusplus.yml index d1d3f22e..253d4c48 100644 --- a/.github/workflows/cplusplus.yml +++ b/.github/workflows/cplusplus.yml @@ -5,6 +5,7 @@ on: paths: - 'cplusplus/**' - '!cplusplus/README.rst' + - '.github/workflows/cplusplus.yml' schedule: - cron: "0 0 1 * *" diff --git a/.github/workflows/csharp-lint.yml b/.github/workflows/csharp-lint.yml index 9eea4469..5fe870b2 100644 --- a/.github/workflows/csharp-lint.yml +++ b/.github/workflows/csharp-lint.yml @@ -5,6 +5,7 @@ on: paths: - 'csharp/**' - '!csharp/README.rst' + - '.github/workflows/csharp-lint.yml' schedule: - cron: "0 0 1 * *" diff --git a/.github/workflows/csharp.yml b/.github/workflows/csharp.yml index 33bbd11e..37caff97 100644 --- a/.github/workflows/csharp.yml +++ b/.github/workflows/csharp.yml @@ -5,6 +5,7 @@ on: paths: - 'csharp/**' - '!csharp/README.rst' + - '.github/workflows/csharp.yml' schedule: - cron: "0 0 1 * *" diff --git a/.github/workflows/eslint.yml b/.github/workflows/eslint.yml index d5e2daa7..84a63101 100644 --- a/.github/workflows/eslint.yml +++ b/.github/workflows/eslint.yml @@ -5,6 +5,7 @@ on: paths: - 'javascript/**' - '!javascript/README.rst' + - '.github/workflows/eslint.yml' pull_request: schedule: - cron: '27 15 * * 5' diff --git a/.github/workflows/fortran.yml b/.github/workflows/fortran.yml index 31aa013e..a468ceda 100644 --- a/.github/workflows/fortran.yml +++ b/.github/workflows/fortran.yml @@ -5,6 +5,7 @@ on: paths: - 'fortran/**' - '!fortran/README.rst' + - '.github/workflows/fortran.yml' schedule: - cron: "0 0 1 * *" diff --git a/.github/workflows/java-lint.yml b/.github/workflows/java-lint.yml index 44dd8cb6..f5ed6563 100644 --- a/.github/workflows/java-lint.yml +++ b/.github/workflows/java-lint.yml @@ -4,6 +4,8 @@ on: push: paths: - 'java/**' + - '!java/README.rst' + - '.github/workflows/java-lint.yml' concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/java.yml b/.github/workflows/java.yml index a888883a..c5771278 100644 --- a/.github/workflows/java.yml +++ b/.github/workflows/java.yml @@ -4,6 +4,8 @@ on: push: paths: - 'java/**' + - '!java/README.rst' + - '.github/workflows/java.yml' concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/javascript.yml b/.github/workflows/javascript.yml index 3a47640c..1f461b4f 100644 --- a/.github/workflows/javascript.yml +++ b/.github/workflows/javascript.yml @@ -5,6 +5,7 @@ on: paths: - 'javascript/**' - '!javascript/README.rst' + - '.github/workflows/javascript.yml' schedule: - cron: "0 0 1 * *" diff --git a/.github/workflows/lua-cov.yml b/.github/workflows/lua-cov.yml index 6ede7670..498e903c 100644 --- a/.github/workflows/lua-cov.yml +++ b/.github/workflows/lua-cov.yml @@ -5,6 +5,7 @@ on: paths: - 'lua/**' - '!lua/README.rst' + - '.github/workflows/lua-cov.yml' schedule: - cron: "0 0 1 * *" diff --git a/.github/workflows/lua-lint.yml b/.github/workflows/lua-lint.yml index 2f63fcf7..31138a83 100644 --- a/.github/workflows/lua-lint.yml +++ b/.github/workflows/lua-lint.yml @@ -5,6 +5,7 @@ on: paths: - 'lua/**' - '!lua/README.rst' + - '.github/workflows/lua-lint.yml' schedule: - cron: "0 0 1 * *" diff --git a/.github/workflows/lua.yml b/.github/workflows/lua.yml index 4f3611d0..edefd47f 100644 --- a/.github/workflows/lua.yml +++ b/.github/workflows/lua.yml @@ -5,6 +5,7 @@ on: paths: - 'lua/**' - '!lua/README.rst' + - '.github/workflows/lua.yml' schedule: - cron: "0 0 1 * *" diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index bcb3e5c1..6d28a2d2 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -18,6 +18,7 @@ on: - '**/*.py' - '**/*.rs' - '.gitattributes' + - '.github/workflows/pages.yml' workflow_dispatch: schedule: - cron: "0 0 * * 1" diff --git a/.github/workflows/python-lint.yml b/.github/workflows/python-lint.yml index 156e2e6d..5b45e2ce 100644 --- a/.github/workflows/python-lint.yml +++ b/.github/workflows/python-lint.yml @@ -5,6 +5,7 @@ on: paths: - 'python/**' - '!python/README.rst' + - '.github/workflows/python-lint.yml' schedule: - cron: "0 0 1 * *" diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 8de2b750..f502bb30 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -5,6 +5,7 @@ on: paths: - 'python/**' - '!python/README.rst' + - '.github/workflows/python.yml' schedule: - cron: "0 0 1 * *" diff --git a/.github/workflows/rust-clippy.yml b/.github/workflows/rust-clippy.yml index 5615d71f..1ac8b655 100644 --- a/.github/workflows/rust-clippy.yml +++ b/.github/workflows/rust-clippy.yml @@ -14,6 +14,7 @@ on: paths: - 'rust/**' - '!rust/README.rst' + - '.github/workflows/rust-clippy.yml' pull_request: schedule: - cron: '32 21 * * 4' diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 53a6ea38..6d46e205 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -5,6 +5,7 @@ on: paths: - 'rust/**' - '!rust/README.rst' + - '.github/workflows/rust.yml' schedule: - cron: "0 0 1 * *" @@ -78,8 +79,8 @@ jobs: if: ${{ matrix.toolchain == 'nightly' }} env: CARGO_INCREMENTAL: '0' - RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests -Copt-level=1' - RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests -Copt-level=1' + RUSTFLAGS: '-Ccodegen-units=1 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests -Copt-level=1' + RUSTDOCFLAGS: '-Ccodegen-units=1 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests -Copt-level=1' RUST_BACKTRACE: 1 - name: rust-grcov diff --git a/python/src/p0096.py b/python/src/p0096.py index 7e4722e3..87d734ee 100644 --- a/python/src/p0096.py +++ b/python/src/p0096.py @@ -1,59 +1,59 @@ -from math import sqrt -from typing import NamedTuple, Sequence, Set, Tuple - -TSet = Set[int] -TSeqSet = Sequence[TSet] -TSeqSeqSet = Sequence[TSeqSet] -TSeqSeqSeqSet = Sequence[TSeqSeqSet] - -TRowCol = Tuple[int, int] -TSquareCoord = Tuple[int, int, int] - -class Grid(NamedTuple): - n: int # minor squares are n x n - n2: int # grid is n2 x n2 - cells: TSeqSet - rows: TSeqSeqSet - cols: TSeqSeqSet - squares: TSeqSeqSeqSet - row_has: TSeqSet - col_has: TSeqSet - square_has: TSeqSeqSet - - def __new__(cls, n2: int = 9): - n = int(sqrt(n2)) - if n * n != n2: - raise ValueError("Grid size must be a perfect square") - - cells = tuple(set(range(1, n2 + 1)) for _ in range(n2 * n2)) - rows = tuple(cells[idx * n2:(idx + 1) * n2] for idx in range(n2)) - cols = tuple(tuple(rows[idx][col] for idx in range(n2)) for col in range(n2)) - squares = tuple( - tuple( - tuple(rows[row * n + (idx // n)][col * n + (idx % n)] for idx in range(n2 * n2)) - for col in range(n) - ) for row in range(n) - ) - row_has = tuple(set() for _ in range(n2)) - col_has = tuple(set() for _ in range(n2)) - square_has = tuple(tuple(set() for _ in range(n)) for _ in range(n)) - - return super().__new__(cls, n, n2, cells, rows, cols, squares, row_has, col_has, square_has) - - def row_col_to_cell(self, row: int, col: int) -> int: - return row * self.n2 + col - - def cell_to_row_col(self, cell_index: int) -> TRowCol: - return divmod(cell_index, self.n2) - - def row_col_to_square(self, row: int, col: int) -> TSquareCoord: - return (row // self.n, col // self.n, (row % self.n) * self.n + (col % self.n)) - - def square_to_row_col(self, square_row: int, square_col: int, idx_in_square: int) -> TRowCol: - return (square_row * self.n + idx_in_square // self.n, square_col * self.n + idx_in_square % self.n) - - def final_value(self, row: int, col: int) -> int: - cell_values = self.rows[row][col] - if len(cell_values) == 1: - return next(iter(cell_values)) - raise ValueError(f"Cell at row {row}, col {col} still has a superposition: {cell_values}") +# from math import sqrt +# from typing import NamedTuple, Sequence, Set, Tuple + +# TSet = Set[int] +# TSeqSet = Sequence[TSet] +# TSeqSeqSet = Sequence[TSeqSet] +# TSeqSeqSeqSet = Sequence[TSeqSeqSet] + +# TRowCol = Tuple[int, int] +# TSquareCoord = Tuple[int, int, int] + +# class Grid(NamedTuple): +# n: int # minor squares are n x n +# n2: int # grid is n2 x n2 +# cells: TSeqSet +# rows: TSeqSeqSet +# cols: TSeqSeqSet +# squares: TSeqSeqSeqSet +# row_has: TSeqSet +# col_has: TSeqSet +# square_has: TSeqSeqSet + +# def __new__(cls, n2: int = 9): +# n = int(sqrt(n2)) +# if n * n != n2: +# raise ValueError("Grid size must be a perfect square") + +# cells = tuple(set(range(1, n2 + 1)) for _ in range(n2 * n2)) +# rows = tuple(cells[idx * n2:(idx + 1) * n2] for idx in range(n2)) +# cols = tuple(tuple(rows[idx][col] for idx in range(n2)) for col in range(n2)) +# squares = tuple( +# tuple( +# tuple(rows[row * n + (idx // n)][col * n + (idx % n)] for idx in range(n2 * n2)) +# for col in range(n) +# ) for row in range(n) +# ) +# row_has = tuple(set() for _ in range(n2)) +# col_has = tuple(set() for _ in range(n2)) +# square_has = tuple(tuple(set() for _ in range(n)) for _ in range(n)) + +# return super().__new__(cls, n, n2, cells, rows, cols, squares, row_has, col_has, square_has) + +# def row_col_to_cell(self, row: int, col: int) -> int: +# return row * self.n2 + col + +# def cell_to_row_col(self, cell_index: int) -> TRowCol: +# return divmod(cell_index, self.n2) + +# def row_col_to_square(self, row: int, col: int) -> TSquareCoord: +# return (row // self.n, col // self.n, (row % self.n) * self.n + (col % self.n)) + +# def square_to_row_col(self, square_row: int, square_col: int, idx_in_square: int) -> TRowCol: +# return (square_row * self.n + idx_in_square // self.n, square_col * self.n + idx_in_square % self.n) + +# def final_value(self, row: int, col: int) -> int: +# cell_values = self.rows[row][col] +# if len(cell_values) == 1: +# return next(iter(cell_values)) +# raise ValueError(f"Cell at row {row}, col {col} still has a superposition: {cell_values}")