Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a Python program to solve the popular Hashiwokakero or Bridges puzzle. The input to your program will be a rectangular array of numbers and
Write a Python program to solve the popular "Hashiwokakero" or "Bridges" puzzle. The input to your program will be a rectangular array of numbers and dots, for example:
caa
ab
Each number represents an "island", while the dots represent the empty space water between the islands. Numbers larger than are indicated by ab or c The aim is to connect all the islands with a network of bridges, satisfying these rules:
all bridges must run horizontally or vertically
bridges are not allowed to cross each other, or other islands
there can be no more than three bridges connecting any pair of islands
the total number of bridges connected to each island must be equal to the number on the island
For example, after reading the line input above, your program might produce the attached out see image below
Note that single bridges are indicated by the characters or pairs of bridges by or and triples by E or # depending on whether they run horizontally or vertically. Water between bridges and islands is indicated by space characters
In some cases, there may be many solutions, in which case your program should only print one solution.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started