There are multiple arrays. How to calculate and how many combinations are available??

Source: Internet
Author: User
Arrays A, B, C, D
The number count is not necessarily the same.
The combination order is fixed A[rand] + B[rand] + C[rand] + D[rand] = Do not repeat the string
How do I get the maximum number of combinations, not repeating strings??


Reply to discussion (solution)

This post was last edited by xuzuning on 2013-10-11 23:59:51

Quantity = Count (A) * COUNT (B) * COUNT (C) * COUNT (D)

$a = Array (' A1 ', ' A2 '); $b = Array (' B1 ', ' B2 '); $c = Array (' C1 ', ' C2 ', ' C3 '); $d = Array (' D1 ', ' D2 ', ' D3 ');p Rint_r (func ($a, $ B, $c, $d)); function func () {  $d = Func_get_args ();  $r = Array_shift ($d);  while ($d) {    $t = array ();    foreach (Array_shift ($d) as $x)      foreach ($r as $y) $t [] = $y. $x;    $r = $t;  }  return $r;}
Array
(
[0] = A1b1c1d1
[1] = A2b1c1d1
[2] = A1B2C1D1
[3] = A2b2c1d1
[4] = A1b1c2d1
[5] = A2b1c2d1
[6] = A1b2c2d1
[7] = A2b2c2d1
[8] = A1b1c3d1
[9] = A2b1c3d1
[Ten] = A1b2c3d1
[One] = A2b2c3d1
[[] = A1b1c1d2
[+] = a2b1c1d2
[+] = a1b2c1d2
[[] = A2b2c1d2
[+] = A1B1C2D2
[+] = A2B1C2D2
[+] = A1B2C2D2
[+] = A2B2C2D2
[+] = a1b1c3d2
[+] = a2b1c3d2
[] = A1b2c3d2
[All] = A2b2c3d2
[] = A1b1c1d3
[+] = A2b1c1d3
[+] = A1b2c1d3
[+] = A2b2c1d3
[+] = a1b1c2d3
[+] = a2b1c2d3
[+] = a1b2c2d3
[+] = a2b2c2d3
[+] = A1b1c3d3
[+] = A2b1c3d3
[+] = A1b2c3d3
[+] = A2b2c3d3
)

Good code. Solved. Thank you.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.