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 6871617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:49:41+00:00 2026-05-27T03:49:41+00:00

I have a matrix like: 0 | 1 | 2 | 3 ————- 7

  • 0

I have a matrix like:

0 | 1 | 2 | 3
-------------
7 | 6 | 5 | 4
-------------
8 | 9 | A | B
-------------
F | E | D | C

in code:

var matrix = new char[][]
{ 
    new char[] { '0', '1', '2', '3' },
    new char[] { '7', '6', '5', '4' },
    new char[] { '8', '9', 'A', 'B' },
    new char[] { 'F', 'E', 'D', 'C' }
};

I need to get all possible combination of this matrix with 5 chars each, but every char must be the next immediate neighbor, for instance, 0,5 and 4,8 are invalid but 0,6 and 3,4 are valid.

This matrix will not be static as is in the sample, it is generated with the hex numbers in any position every time.

Thanks!

  • 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-27T03:49:42+00:00Added an answer on May 27, 2026 at 3:49 am

    Just for fun – Delphi code. ‘shl’ is left shift (<<), strings are one-based. Borders are added around the matrix as sentinels to simplify checks.

    Some additional comments: I use 6×6 matrix – 4×4 core with digits, and one-cell width outer border. 36 bits of Int64 are used as sentinels. Bit value of 1 denotes border or visited cell. Procedure StartTravel initiates path finding from some starting cell of core. Path finding goes like DFS (deep-first search), but interrupts when path length becomes 5.

    const
      Directions: array[0..3] of Integer = (-1, -6, 1, 6);
    
    var
      Digits: string;
      Mask: Int64;
      i, j: Integer;
    
      procedure Travel(AFrom: Integer; Visited: Int64; Path: string);
      var
        i, Dir: Integer;
        NewMask: Int64;
      begin
        if Length(Path) = 5 then
          PrintOut(Path)
        else
          for i := 0 to 3 do begin
            Dir := Directions[i];
            NewMask := 1 shl (AFrom + Dir);
            if (Visited and NewMask) = 0 then
              Travel(AFrom + Dir, Visited or NewMask, Path + Digits[AFrom + Dir + 1]);
          end;
      end;
    
      procedure Init;
      var
        i: Integer;
      begin
        Digits := '-------0123--7654--89AB--FEDC-------';
        Mask := 0;
        for i := 1 to Length(Digits) do
          if Digits[i] = '-' then
            Mask := Mask or (1 shl (i - 1));
      end;
    
      procedure StartTravel(Row, Col: Integer);
      var
        APos: Integer;
      begin
        APos := Row * 6 + Col + 7;
        Travel(APos, Mask or (1 shl APos), Digits[APos + 1]);
      end;
    
    begin
      Init;
      for i := 0 to 3 do
        for j := 0 to 3 do
          StartTravel(i, j);
    
    432 combinations:
    01234
    01256
    01254
    0125A
    01678
    01652
    01654
    0165A
    01698
    0169A
    0169E
    07612
    07652
    ....
    CBADE
    CB456
    CB452
    CB45A
    CB432
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to have a 4x4 matrix like this: 1 2 3 4 5
I have a function like this: MyFunction(double matrix[4][4]) {/*do stuff*/} I am calling this
Say I have a matrix that looks something like this: {{foobar, 77},{faabar, 81},{foobur, 22},{faabaa,
let's say I have a matrix (array) like this example, but much larger: 0
For instance I have a matrix like this: |1 2 3| |4 5 6|
If I have a matrix like this A = [1 2; 3 4]; I
Assume I have a matrix something like this : 1 1 1 0 0
let's say I have a matrix like this: [,1] [,2] [,3] [,4] [,5] [,6]
I have a matrix called matrix that looks like this: charge convexhull_xCoor convexhull_yCoor id
I have a matrix (Data) which looks like this: (start) (stop) (strand) (gene number)

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.