Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Solving peg solitaire with a golden peg: bitmasks, a dead-position memo and backward puzzle generation

Peg solitaire is a good small search problem: the board is tiny, the rules fit in one sentence, and a naive solver can still waste a lot of time. I wrote a dependency-free JavaScript solver for a browser puzzle and want to show the two ideas that matter, plus a twist that changes the search slightly. The code is in the peg-solver repository (MIT licence). It is the same logic that checks the…

Peg solitaire is a compact search problem that can be solved using a JavaScript solver. The board is represented as an array of strings, with 'o' indicating a hole and '.' signifying an empty space. The solver uses depth-first search and a dead-position memo to avoid re-exploiting the same subtrees, making it more efficient. A golden peg is added to the classic game with the rules that it cannot be jumped over and must be the last peg left.

This twist is implemented by adding an extra condition in the move generation code and modifying the win test. To generate solvable puzzles, the game is run in reverse, starting from a single peg and making reverse jumps. The difficulty of the search grows roughly threefold for every two extra pegs, which makes the generator comfortable with the needed sizes for a phone game.

The solver was tested on 200 puzzles per setting with a budget of 1 million nodes, and all puzzles were solved without exceeding the budget.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

Budgeting TRON Bandwidth for an Energy rental and a USDT transfer

If you rent TRON Energy by sending TRX from the same wallet that will send USDT, budget for two transactions . The rental payment itself can use Bandwidth before the USDT transfer is signed.

  • Budget for TRX payment and USDT transfer when renting TRON Energy
  • Verify sender's Bandwidth using Resources view on TRONSCAN
  • Ensure separate balances for Bandwidth and Energy consumption

Inside Meta's Partner Ecosystem: How Governments, Trusted Organizations, and Major Businesses Access Specialized Support

Inside Meta's Partner Ecosystem: How Governments, Trusted Organizations, and Major Businesses Access Specialized Support Understanding Meta's official escalation channels, technical partnerships…

  • Meta offers specialized support channels for various partner categories.
  • Access to these channels depends on partner's role, permissions, products, and eligibility.
  • These channels do not permit reversing enforcement decisions or recovering accounts for others.

B2C SaaS abroad: When do you actually have to register for VAT/GST?

Getting your first customer from another country is exciting. Someone in Lisbon, whom you've never met, has decided your little SaaS product is worth €12 a month.

  • SaaS businesses selling abroad may face VAT/GST obligations in multiple countries.
  • Thresholds for tax registration vary by country, e.g., Norway and Canada have specific limits.
  • US sales tax rules are complex due to state-level economic nexus requirements.

More from Monday 23 November →