‹ BackHN Continuity

Thread

Solving a corn puzzle with CP-SAT

37 points · 20 comments · luu

  1. JoeAltmaier · · focus · HN ↗
    Back in the day BYTE magazine had a puzzle contest - solve the 8-queens problem and find all the solutions.

    As a kid, it seemed obvious to me that a good model was the digits 1 through 8, representing the row that a queen would be in. Doing a recursive backtracker on an ordering of the digits and testing each pair for diagonal (digit i minus digit j was equal to +/- i-j) and my BASIC program spit out the solutions in twenty minutes.

    I didnt enter the contest because I figured everybody would do that. Turns out when the editor published the 'best' solutions, they all, every single one, modeled the board as an 8 by 8 array and ran around following diagonals iteratively. And took hours to complete.

    Anyway, choosing a good solution model is most of the problem solved.

    1. IceDane · · focus · HN ↗

      [dead]

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.