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

The Archive Base Latest Questions

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

i need to discover all possible combinations for some arrays that have an specific

  • 0

i need to discover all possible combinations for some arrays that have an specific char.

let me explain.

i have this text that have vectors organized as rows:

1342;-;+;V;+;-;V;V;V;ND;-;-;ND;ND;+;+;ND;-;ND;ND;ND;-;+;ND;+;-;-;-;ND;-;-;ND;ND;-;ND;ND;F;ND
2343;-;-;-;-;-;-;ND;-;ND;-;-;ND;ND;-;V;ND;V;ND;ND;ND;-;+;ND;-;-;-;V;ND;V;-;ND;ND;-;ND;ND;O;ND
2344;-;-;-;-;-;-;ND;-;ND;-;ND;ND;ND;ND;+;ND;+;ND;ND;ND;-;+;ND;+;-;-;-;ND;V;ND;ND;ND;-;ND;ND;O;ND
2345;-;V;V;+;V;V;ND;-;+;-;-;-;ND;-;V;ND;+;ND;V;ND;-;+;ND;-;-;-;-;V;-;+;ND;ND;-;-;+;F;-

each row is an vector..the attributes values are separeted by “;”

  • all possible values are: numbers, +, -, O, F, ND and ‘V’
  • but the char V means + and –

what i need to to is to check for EACH ROW when the vector has in any attibute the char “V”
because if have it means that this row must be replicated to all possibilities of V.

see this little example:

109 ; + ; - ; V ; ND ; +

i checked that this row has one or more than one “V” so now will calculate all possibilities that can be generated for this row

as we know V = + and – so this one row will generate:

109 ; + ; - ;  +  ; ND ; +
109 ; + ; - ;  -  ; ND ; +

as we have just one V so we will have 2 possibilities… the problem is when there is more than one ‘V’ .. how to calculate all combinations to it..

when creating the new text with all rows combinations the new text must not contain the origin row with the ‘V’.
note that all other attributes values remains the same.

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-05-30T22:01:05+00:00Added an answer on May 30, 2026 at 10:01 pm

    You can do it recursively. This solution assumes a limited dataset, where we wouldn’t run the risk of exhausting memory.

    <?php
    
    $input = "5;V\n4;3";
    
    $input_arr = explode("\n", $input);
    foreach( $input_arr as $vector ){
        $output = replace_v(explode(';', $vector));
        foreach( $output as $output_line ){
            echo implode(';', $output_line) . "\n";
        }
    }
    
    function replace_v($input) {
        if( $key = array_search('V', $input) ){
            $a = $b = $input;
            $a[$key] = '-';
            $b[$key] = '+';
            return array_merge(replace_v($a), replace_v($b));
        }
        return array($input);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose you need to discover all possible permutations of 'n' distinct characters, say 'a',
I have a widget where I need to display some text on one row.
I have implimented the example: http://www.datatables.net/examples/server_side/server_side.html only to discover that this example gets all
need ask you about some help. I have web app running in Net 2.0.
Need to insert selected text on the page into textarea. There must be some
I need to be able to return a list of files that meet some
I have a WCF project in Visual Studio that I need to deploy to
Say I have a bunch of code for all controls, yet I need subclasses
What bundles do I need to install? At least, this would have to be
Is it possible to dynamically discover the properties of a PHP object? I have

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.