USA1998 P4
open: first valid proof sets the record
Compfiles · Usa · Apache-2.0
Copyright (c) 2023 David Renshaw. All rights reserved. Authors: David Renshaw
Statement
import Mathlib.Data.ZMod.Basic
import Mathlib.Order.Bounds.Basic
import Mathlib.Tactic
theorem _root_.LeanGolf.compfiles.usa1998_p4 : IsLeast possible_num_clicks min_clicksTrusted statement context
noncomputable section
namespace Usa1998P4
def chessboard : Type := Fin 98 × Fin 98
def coloring := chessboard → ZMod 2
def all_same_color (f : coloring) : Prop :=
∃ c : ZMod 2, ∀ s : chessboard, f s = c
structure Rectangle where
x : ℕ
y : ℕ
width : ℕ
height : ℕ
def recolor_rect (f : coloring) (r : Rectangle) : coloring :=
fun ⟨x, y⟩ ↦ if r.x ≤ x.val ∧
r.y ≤ y.val ∧
x.val < r.x + r.width ∧
y.val < r.y + r.height
then
f ⟨x, y⟩ + 1
else
f ⟨x, y⟩
def start_coloring : coloring := fun ⟨x, y⟩ ↦ x.val + y.val
def possible_num_clicks : Set ℕ :=
{ n : ℕ | ∃ rs : List Rectangle,
(all_same_color (rs.foldl recolor_rect start_coloring) ∧
rs.length = n) }
abbrev min_clicks : ℕ := 98