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

  • SEARCH
  • Home
  • 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 9105499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:07:24+00:00 2026-06-17T02:07:24+00:00

I have a matrix and each cell has a boolean property. I need to

  • 0

I have a matrix and each cell has a boolean property. I need to determine a cycle, starting from a cell that has the boolean property false, and this cycle must contain only cells that have that boolean property set to true (except the starting cell, obviously). Another condition is that any two consecutive cells in the cycle must be on the same row (or on the same column), and that three consecutive cells in the cycle must not be on the same row (or on the same column).
You can actually jump from one cell to another, they don’t have to be neighbours, they just have to be on the same row or column.
Thank you.

  • 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-06-17T02:07:25+00:00Added an answer on June 17, 2026 at 2:07 am

    Update: I missed that a move is not required to be between two adjacent cells – this enlarges the number of possible moves at each step but does not really change the general idea.

    The easiest implementation is probably depth-first search – you start at the starting cell and look at all possible moves – except for the first move there are at most three possible moves. For each possible move you do the same recursively until you reach the starting cell again or there is no possible move remaining. In the later case you track back one move and try the next possibility if there is one remaining.

    You have to pass the direction of the last move along with the recursive call because this direction is not valid for the next move. If it is not allowed to visit cells several times you have to track the visited cells, too, and unmark them when tracking back. If it is allowed to visit cells several times you have to track the direction you left a cell when you visited it before in order to avoid cycles.

    Using breath-first search instead of depth-first search will avoid trying long paths that are no solutions at the cost of keeping book of a large number of partial solutions. A* search might be another option to speed this up.

    Side note: It may be the case that there is no value in visiting a cell several times because you could have take the other move directly when visiting the cell for the first time. The exception is doing the move not allowed when entering the cell for the first time
    but I am not sure if such a path is possible.

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

Sidebar

Related Questions

I have a matrix, each cell has an RGB value. I want to project
I have a SurfaceView where I'm drawing a matrix (game board) and each cell
Have a matrix report now that has Position, Hours and Wages for a location
I have a matrix of objects that contains data in this form: name A,2,name
I have some simple code that represents a graph using a square boolean matrix
I have a matrix with each column represents a feature over time. I need
I have a matrix(5800 rows and 350 columns) of numbers. Each cell is either
If I have a 20x1 cell matrix where each cell is a 1x50 cell
I have this cells array which is came from a mat lab code that
I have a string matrix with N rows and 2 columns. Each cell stores

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.