Details
Star Battle is a logic puzzle on a grid divided into regions: place stars
so that every row, column and region contains one star and no two stars
touch, not even diagonally. This hole uses the one-star variant on a
9 × 9 board with 9 regions.
The board is drawn with Unicode box-drawing characters: heavy lines border
the regions and the frame, dotted lines separate cells within a region,
and every cell shows the digit (1-9) of its region. Write a program that,
given such a board as its argument, prints the same board with a star in
place of the digit of each of the 9 cells that solve it.
For example, given this board:
┏━━━━━━━┳━━━━━━━━━━━━━━━━━━━┳━━━━━━━┓
┃ 7 ∙ 7 ┃ 3 ∙ 3 ∙ 3 ∙ 3 ∙ 3 ┃ 1 ∙ 1 ┃
┃∙∙∙∙∙∙∙┗━━━━━━━┓∙∙∙∙∙∙∙┏━━━┛∙∙∙┏━━━┫
┃ 7 ∙ 7 ∙ 7 ∙ 7 ┃ 3 ∙ 3 ┃ 1 ∙ 1 ┃ 4 ┃
┃∙∙∙∙∙∙∙∙∙∙∙┏━━━┛∙∙∙∙∙∙∙┗━━━━━━━┫∙∙∙┃
┃ 7 ∙ 7 ∙ 7 ┃ 3 ∙ 3 ∙ 3 ∙ 3 ∙ 3 ┃ 4 ┃
┃∙∙∙∙∙∙∙∙∙∙∙┃∙∙∙∙∙∙∙┏━━━┓∙∙∙┏━━━┻━━━┫
┃ 7 ∙ 7 ∙ 7 ┃ 3 ∙ 3 ┃ 6 ┃ 3 ┃ 6 ∙ 6 ┃
┃∙∙∙∙∙∙∙∙∙∙∙┃∙∙∙┏━━━┛∙∙∙┗━━━┛∙∙∙∙∙∙∙┃
┃ 7 ∙ 7 ∙ 7 ┃ 3 ┃ 6 ∙ 6 ∙ 6 ∙ 6 ∙ 6 ┃
┣━━━┳━━━┓∙∙∙┣━━━╋━━━┓∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙┃
┃ 5 ┃ 9 ┃ 7 ┃ 2 ┃ 8 ┃ 6 ∙ 6 ∙ 6 ∙ 6 ┃
┃∙∙∙┃∙∙∙┣━━━┛∙∙∙┗━━━┫∙∙∙┏━━━━━━━┓∙∙∙┃
┃ 5 ┃ 9 ┃ 2 ∙ 2 ∙ 2 ┃ 6 ┃ 2 ∙ 2 ┃ 6 ┃
┃∙∙∙┗━━━┫∙∙∙∙∙∙∙┏━━━┛∙∙∙┃∙∙∙┏━━━┛∙∙∙┃
┃ 5 ∙ 5 ┃ 2 ∙ 2 ┃ 6 ∙ 6 ┃ 2 ┃ 6 ∙ 6 ┃
┃∙∙∙┏━━━┛∙∙∙∙∙∙∙┗━━━━━━━┛∙∙∙┗━━━━━━━┫
┃ 5 ┃ 2 ∙ 2 ∙ 2 ∙ 2 ∙ 2 ∙ 2 ∙ 2 ∙ 2 ┃
┗━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
print this solution:
┏━━━━━━━┳━━━━━━━━━━━━━━━━━━━┳━━━━━━━┓
┃ 7 ∙ 7 ┃ 3 ∙ 3 ∙ 3 ∙ 3 ∙ 3 ┃ * ∙ 1 ┃
┃∙∙∙∙∙∙∙┗━━━━━━━┓∙∙∙∙∙∙∙┏━━━┛∙∙∙┏━━━┫
┃ 7 ∙ 7 ∙ 7 ∙ 7 ┃ 3 ∙ * ┃ 1 ∙ 1 ┃ 4 ┃
┃∙∙∙∙∙∙∙∙∙∙∙┏━━━┛∙∙∙∙∙∙∙┗━━━━━━━┫∙∙∙┃
┃ 7 ∙ 7 ∙ 7 ┃ 3 ∙ 3 ∙ 3 ∙ 3 ∙ 3 ┃ * ┃
┃∙∙∙∙∙∙∙∙∙∙∙┃∙∙∙∙∙∙∙┏━━━┓∙∙∙┏━━━┻━━━┫
┃ 7 ∙ 7 ∙ * ┃ 3 ∙ 3 ┃ 6 ┃ 3 ┃ 6 ∙ 6 ┃
┃∙∙∙∙∙∙∙∙∙∙∙┃∙∙∙┏━━━┛∙∙∙┗━━━┛∙∙∙∙∙∙∙┃
┃ 7 ∙ 7 ∙ 7 ┃ 3 ┃ 6 ∙ 6 ∙ * ∙ 6 ∙ 6 ┃
┣━━━┳━━━┓∙∙∙┣━━━╋━━━┓∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙┃
┃ 5 ┃ 9 ┃ 7 ┃ 2 ┃ * ┃ 6 ∙ 6 ∙ 6 ∙ 6 ┃
┃∙∙∙┃∙∙∙┣━━━┛∙∙∙┗━━━┫∙∙∙┏━━━━━━━┓∙∙∙┃
┃ 5 ┃ * ┃ 2 ∙ 2 ∙ 2 ┃ 6 ┃ 2 ∙ 2 ┃ 6 ┃
┃∙∙∙┗━━━┫∙∙∙∙∙∙∙┏━━━┛∙∙∙┃∙∙∙┏━━━┛∙∙∙┃
┃ 5 ∙ 5 ┃ 2 ∙ * ┃ 6 ∙ 6 ┃ 2 ┃ 6 ∙ 6 ┃
┃∙∙∙┏━━━┛∙∙∙∙∙∙∙┗━━━━━━━┛∙∙∙┗━━━━━━━┫
┃ * ┃ 2 ∙ 2 ∙ 2 ∙ 2 ∙ 2 ∙ 2 ∙ 2 ∙ 2 ┃
┗━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Every board has a unique solution. Reading the digits is just taking every
fourth character of every second line; the drawn lines are only a visual
aid.
External links:
Puzzle Star Battle,
Puzzles Wiki
05AB1E is an experimental language, solutions won't contribute to
scoring until the language goes live. Please leave feedback on the
GitHub issue.
APL is an experimental language, solutions won't contribute to
scoring until the language goes live. Please leave feedback on the
GitHub issue.
Arturo is an experimental language, solutions won't contribute to
scoring until the language goes live. Please leave feedback on the
GitHub issue.
Befunge is an experimental language, solutions won't contribute to
scoring until the language goes live. Please leave feedback on the
GitHub issue.
BQN is an experimental language, solutions won't contribute to
scoring until the language goes live. Please leave feedback on the
GitHub issue.
CJam is an experimental language, solutions won't contribute to
scoring until the language goes live. Please leave feedback on the
GitHub issue.
CoffeeScript is an experimental language, solutions won't contribute to
scoring until the language goes live. Please leave feedback on the
GitHub issue.
Egel is an experimental language, solutions won't contribute to
scoring until the language goes live. Please leave feedback on the
GitHub issue.
Fennel is an experimental language, solutions won't contribute to
scoring until the language goes live. Please leave feedback on the
GitHub issue.
Harbour is an experimental language, solutions won't contribute to
scoring until the language goes live. Please leave feedback on the
GitHub issue.
Hare is an experimental language, solutions won't contribute to
scoring until the language goes live. Please leave feedback on the
GitHub issue.
Haxe is an experimental language, solutions won't contribute to
scoring until the language goes live. Please leave feedback on the
GitHub issue.
Hush is an experimental language, solutions won't contribute to
scoring until the language goes live. Please leave feedback on the
GitHub issue.
Hy is an experimental language, solutions won't contribute to
scoring until the language goes live. Please leave feedback on the
GitHub issue.
Knight is an experimental language, solutions won't contribute to
scoring until the language goes live. Please leave feedback on the
GitHub issue.
Lily is an experimental language, solutions won't contribute to
scoring until the language goes live. Please leave feedback on the
GitHub issue.
Luau is an experimental language, solutions won't contribute to
scoring until the language goes live. Please leave feedback on the
GitHub issue.
Odin is an experimental language, solutions won't contribute to
scoring until the language goes live. Please leave feedback on the
GitHub issue.
Picat is an experimental language, solutions won't contribute to
scoring until the language goes live. Please leave feedback on the
GitHub issue.
Qore is an experimental language, solutions won't contribute to
scoring until the language goes live. Please leave feedback on the
GitHub issue.
Racket is an experimental language, solutions won't contribute to
scoring until the language goes live. Please leave feedback on the
GitHub issue.
Rebol is an experimental language, solutions won't contribute to
scoring until the language goes live. Please leave feedback on the
GitHub issue.
Rexx is an experimental language, solutions won't contribute to
scoring until the language goes live. Please leave feedback on the
GitHub issue.
Scala is an experimental language, solutions won't contribute to
scoring until the language goes live. Please leave feedback on the
GitHub issue.
Squirrel is an experimental language, solutions won't contribute to
scoring until the language goes live. Please leave feedback on the
GitHub issue.
Stax is an experimental language, solutions won't contribute to
scoring until the language goes live. Please leave feedback on the
GitHub issue.
Uiua is an experimental language, solutions won't contribute to
scoring until the language goes live. Please leave feedback on the
GitHub issue.
Umka is an experimental language, solutions won't contribute to
scoring until the language goes live. Please leave feedback on the
GitHub issue.
Vala is an experimental language, solutions won't contribute to
scoring until the language goes live. Please leave feedback on the
GitHub issue.
Vyxal is an experimental language, solutions won't contribute to
scoring until the language goes live. Please leave feedback on the
GitHub issue.
ZuzuScript is an experimental language, solutions won't contribute to
scoring until the language goes live. Please leave feedback on the
GitHub issue.