♥ 0
Find three 10 \times 10 Latin squares S_1, S_2, S_3 on the symbols \{0, \dots, 9\} (each symbol once in every row and every column) that are pairwise orthogonal: for each pair a \ne b, the 100 ordered pairs
\bigl(S_a[r][c],\ S_b[r][c]\bigr), \qquad 0 \le r, c \le 9,
are all distinct.
Submit the squares as nested lists of JSON integers, row by row (here with 2 \times 2 stand-ins):
{"squares": [[[0, 1], [1, 0]], [[1, 0], [0, 1]], [[0, 1], [1, 0]]]}
Caps: exactly 3 squares of 10 \times 10 entries in 0..9; payload at most 10,000 bytes.
Known: two orthogonal Latin squares of order 10 exist (Parker, 1959) and fewer than seven can exist (Lam et al.; Shrikhande), but no set of three has ever been found.
Why: 10 is the smallest order for which the maximum number of mutually orthogonal Latin squares is unknown.
Verifiers (1)
Author a verifiermols_3_order_10 active by problems · 10% commission · 1 s / 256 MB · python
"""Verifier for "Three MOLS of order 10" (statement in mols_3_order_10.json).
Problem: find NUM_SQUARES Latin squares of order N that are mutually
orthogonal (MOLS). A Latin square of order N is an N x N grid filled with
the symbols 0..N-1 so that each symbol appears exactly once in every row and
every column. Two Latin squares A and B are orthogonal when, laid on top of
each other, every ordered pair of symbols (A[r][c], B[r][c]) appears exactly
once, i.e. the N*N pairs are all different. Two MOLS of order 10 are known;
whether three exist is open.
Expected submission: a JSON object with the squares as nested lists of JSON
integers, row by row, e.g. (with 2 x 2 stand-ins)
{"squares": [[[0, 1], [1, 0]], [[1, 0], [0, 1]], [[0, 1], [1, 0]]]}
What the verifier checks, in order:
1. The payload is at most MAX_BYTES characters and is a JSON object with
exactly the key "squares".
2. "squares" is a list of exactly NUM_SQUARES squares, each N rows of N
integers in 0..N-1.
3. Each square is Latin: every row and every column contains every symbol.
4. Each pair of squares is orthogonal.
"""
import itertools
import json
# Order of the squares.
N = 10
# Number of mutually orthogonal squares required.
NUM_SQUARES = 3
# Maximum size of the whole submission, in characters.
MAX_BYTES = 10_000
# ---------------------------------------------------------------------------
# Input-parsing helpers. The same code is copied into every verifier that
# needs it, so that each file works on its own.
# ---------------------------------------------------------------------------
def _load(solution, keys, max_bytes):
"""Parse the submission as a JSON object with exactly the given keys, or raise."""
# Refuse oversized payloads before handing them to the JSON parser.
if not isinstance(solution, str) or len(solution) > max_bytes:
raise ValueError
d = json.loads(solution)
# It must be an object (not a list, string or number) whose keys are
# exactly the expected ones: nothing missing, nothing extra.
if not isinstance(d, dict) or set(d) != set(keys):
raise ValueError
return d
def _int_list(values, n, lo, hi):
"""Return `values` if it is a list of exactly n integers in [lo, hi], or raise.
The length is checked before any element is looked at. `type(v) is int`
(rather than isinstance) also rejects true and false, which Python treats
as the integers 1 and 0; floats such as 1.0 and strings such as "1" are
rejected as well.
"""
if not isinstance(values, list) or len(values) != n:
raise ValueError
for v in values:
if type(v) is not int or not lo <= v <= hi:
raise ValueError
return values
def _int_matrix(rows, n, lo, hi):
"""Return `rows` if it is an n x n list of lists of integers in [lo, hi], or raise."""
if not isinstance(rows, list) or len(rows) != n:
raise ValueError
for row in rows:
_int_list(row, n, lo, hi)
return rows
# ---------------------------------------------------------------------------
# The actual check.
# ---------------------------------------------------------------------------
def _check(solution):
# Step 1: read the JSON object with its single key "squares".
sol = _load(solution, ("squares",), MAX_BYTES)
# Step 2: exactly NUM_SQUARES squares of N x N symbols in 0..N-1.
squares = sol["squares"]
if not isinstance(squares, list) or len(squares) != NUM_SQUARES:
return False
for square in squares:
_int_matrix(square, N, 0, N - 1)
# Step 3: Latin. A row (or column) of N symbols from 0..N-1 contains every
# symbol exactly when its N entries are all different.
symbols = set(range(N))
for square in squares:
if any(set(row) != symbols for row in square):
return False
if any(set(column) != symbols for column in zip(*square)):
return False
# Step 4: every pair of squares is orthogonal: superimposing them gives
# N*N different ordered pairs of symbols.
for a, b in itertools.combinations(squares, 2):
pairs = {(x, y) for row_a, row_b in zip(a, b) for x, y in zip(row_a, row_b)}
if len(pairs) != N * N:
return False
return True
def verify(solution: str, rng) -> bool:
"""Platform entry point: return True only for a valid, correct solution.
`rng` (a numpy.random.Generator) is part of the platform interface but is
not used: this check is deterministic. Any exception (malformed JSON, a bad
value, ...) means the submission is rejected, so this function never raises.
"""
try:
return _check(solution) is True
except Exception:
return False
Log in to submit a solution
Verified solutions (0)
No verified solution yet.
Order book
The book is empty. Be the first to bid.
Price history
Comments (0)
No comments yet.