Skip to content

Commit

Permalink
Fix language version errors, GA push filters
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Dec 3, 2024
1 parent 355be0e commit 3a14936
Show file tree
Hide file tree
Showing 21 changed files with 83 additions and 61 deletions.
1 change: 1 addition & 0 deletions .github/workflows/c-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
paths:
- 'c/**'
- '!c/README.rst'
- '.github/workflows/c-lint.yml'
schedule:
- cron: "0 0 1 * *"

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/c.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
paths:
- 'c/**'
- '!c/README.rst'
- '.github/workflows/c.yml'
schedule:
- cron: "0 0 1 * *"

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ on:
- 'javascript/**'
- 'python/**'
- '!*/README.rst'
- '.github/workflows/codeql.yml'
pull_request:
schedule:
- cron: '29 10 * * 4'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/cplusplus-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
paths:
- 'cplusplus/**'
- '!cplusplus/README.rst'
- '.github/workflows/cplusplus-lint.yml'
schedule:
- cron: "0 0 1 * *"

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/cplusplus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
paths:
- 'cplusplus/**'
- '!cplusplus/README.rst'
- '.github/workflows/cplusplus.yml'
schedule:
- cron: "0 0 1 * *"

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/csharp-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
paths:
- 'csharp/**'
- '!csharp/README.rst'
- '.github/workflows/csharp-lint.yml'
schedule:
- cron: "0 0 1 * *"

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/csharp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
paths:
- 'csharp/**'
- '!csharp/README.rst'
- '.github/workflows/csharp.yml'
schedule:
- cron: "0 0 1 * *"

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
paths:
- 'javascript/**'
- '!javascript/README.rst'
- '.github/workflows/eslint.yml'
pull_request:
schedule:
- cron: '27 15 * * 5'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/fortran.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
paths:
- 'fortran/**'
- '!fortran/README.rst'
- '.github/workflows/fortran.yml'
schedule:
- cron: "0 0 1 * *"

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/java-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
paths:
- 'java/**'
- '!java/README.rst'
- '.github/workflows/java-lint.yml'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
paths:
- 'java/**'
- '!java/README.rst'
- '.github/workflows/java.yml'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/javascript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
paths:
- 'javascript/**'
- '!javascript/README.rst'
- '.github/workflows/javascript.yml'
schedule:
- cron: "0 0 1 * *"

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/lua-cov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
paths:
- 'lua/**'
- '!lua/README.rst'
- '.github/workflows/lua-cov.yml'
schedule:
- cron: "0 0 1 * *"

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/lua-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
paths:
- 'lua/**'
- '!lua/README.rst'
- '.github/workflows/lua-lint.yml'
schedule:
- cron: "0 0 1 * *"

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/lua.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
paths:
- 'lua/**'
- '!lua/README.rst'
- '.github/workflows/lua.yml'
schedule:
- cron: "0 0 1 * *"

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ on:
- '**/*.py'
- '**/*.rs'
- '.gitattributes'
- '.github/workflows/pages.yml'
workflow_dispatch:
schedule:
- cron: "0 0 * * 1"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/python-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
paths:
- 'python/**'
- '!python/README.rst'
- '.github/workflows/python-lint.yml'
schedule:
- cron: "0 0 1 * *"

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
paths:
- 'python/**'
- '!python/README.rst'
- '.github/workflows/python.yml'
schedule:
- cron: "0 0 1 * *"

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/rust-clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ on:
paths:
- 'rust/**'
- '!rust/README.rst'
- '.github/workflows/rust-clippy.yml'
pull_request:
schedule:
- cron: '32 21 * * 4'
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
paths:
- 'rust/**'
- '!rust/README.rst'
- '.github/workflows/rust.yml'
schedule:
- cron: "0 0 1 * *"

Expand Down Expand Up @@ -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
Expand Down
118 changes: 59 additions & 59 deletions python/src/p0096.py
Original file line number Diff line number Diff line change
@@ -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}")

0 comments on commit 3a14936

Please sign in to comment.