Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4114918
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:30:57+00:00 2026-05-20T22:30:57+00:00

I have to figure out an algorithm, which finds a solution for the Connect

  • 0

I have to figure out an algorithm, which finds a solution for the Connect the Walls game.

In Connect the Wall we’ve got rectangle shape board divided into equal, square cells. In each cell we can put a diagonal wall (directed from left upper corner to right bottom or from left bottom corner to right upper). We have to put walls in all the empty spaces according to the following rules:

  1. Each cell must contain a wall
  2. The walls must not form closed loop (we can’t “brick up”)
  3. The number of walls connecting to a pillar must match the number written
    on the pillar
  4. Additionally some cells might contain a wall which we can’t move.

Connect the walls online game

Please help.

EDIT:

Ok. I’ve managed to write simplifying algorithm in C. I need someone to check me. It works for now like this: Steps

Moreover, I have a question about the last brute-force step.
Can I pick a random cell for start? (maybe there is faster way)
The brute-force algorithm as I understand it:

  1. Choose the first cell and mark it / or \
  2. Check if it meets pillars criteria and if there are no cycles
  3. If everything’s ok go to the empty neighbour cell, if not back up and
    change wall direction in previous cell
    (if we didn’t do it before)
  4. Loop until we won’t have empty cells on our board. Is that right?

And one more issue concerning fast cycle check.
I’ve figured out that I could use disjoint sets and connected components of graph features.
So…We keep connected components of graph in find-union structure.
If a new recently added edge (wall) connects points from the same connected component – it’s a cycle.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T22:30:58+00:00Added an answer on May 20, 2026 at 10:30 pm

    Fun game. Sort of like mine-sweeper.

    Are you interested in only a way to get the solution? In that case, it is a simple tree-search. Sort of like solving a maze. Backtracking and stuff. Easy to prune subtrees since the restrictions are quite tight.

    A quick way? Look for all “2” pillars on the border. Fill them all first. Also fill the “1” pillars at corners. Mark all walls connecting to “0” pillars as impossible, but mark all the other directions (because all those squares must be marked).

    Then for each pillar that has the requisit numbers of walls, mark all other connecting walls to that pillar as impossible, mark all other directions. Then mark all the other walls connected to “3” pillars with one impossible wall. The mark all the other walls connected to “2” pillars with two impossible walls. Then “1” pillars. Loop.

    After simplifying your board like this, you’ll have to do a normal tree search on the remaining unspecified walls. Mark one potential wall, then loop through the above again to eliminate possibilities.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WPF ListView which repeats the data vertically. I cannot figure out
I have not used generics much and so cannot figure out if it is
I'm trying to figure out if there is any way to have a .NET
I have an ASP.NET page where I need to figure out where the style
It seems obvious that some people have been able to figure out how to
I am fairly new to Emacs and I have been trying to figure out
I have a ListView control, and I'm trying to figure out the easiest/best way
I have Windows Vista MCML app, and I need to figure out the current
I have a pretty good understanding of Javascript, except that I can't figure out
I'm sure this is easy but I can't figure it out: I have an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.