Skip to content

Latest commit

 

History

History
40 lines (32 loc) · 1.54 KB

File metadata and controls

40 lines (32 loc) · 1.54 KB

Strategy

Goals

  • Find a valid 3x3 magic square of distinct perfect squares, or produce the strongest near misses.
  • Compare algorithm variants under a consistent scoring and timing budget.
  • Iterate by tweaking promising algorithms based on observed outputs.

Core Scoring (near-miss ranking)

Let the 3x3 entries be integers (not necessarily squares). Compute the 8 line sums and set the target magic sum to the average of those sums.

  • Magic-ness error:
    • E_sum = sqrt((1/8) * sum((S_k - M)^2))
  • Square-ness error:
    • E_sq = sqrt((1/9) * sum((x - round(sqrt(x))^2)^2))
  • Distinctness penalty:
    • E_dist = 9 - count(distinct entries)

Optional normalization (scale-free):

  • E_sum_norm = E_sum / max(1, |M|)
  • E_sq_norm = E_sq / max(1, median(x))

Combined score (lower is better):

  • Score = w1 * E_sum_norm + w2 * E_sq_norm + w3 * E_dist
  • Default weights: w1 = 1.0, w2 = 1.0, w3 = 2.0

Experiment Loop

  1. Run algorithm variant under a fixed time budget.
  2. Record best candidate, score, throughput, and time to first decent near miss.
  3. Review the structure of top candidates and tweak parameters or heuristics.
  4. Re-run and compare against prior results.

Output Tracking

  • Keep a "hall of fame" of best candidates and scores per algorithm variant.
  • Log parameter settings and performance for repeatability.

Success Criteria

  • Exact hit: all entries are perfect squares, distinct, and all 8 line sums equal.
  • Near-miss: minimum score under agreed weights; prioritize low E_sum and zero E_sq, then reduce E_dist.