Results 1 to 2 of 2

Thread: how to code to do every possible combination?

  1. #1
    Frenzied Member
    Join Date
    Jul 05
    Posts
    1,149

    how to code to do every possible combination?

    I'm trying to figure out how to test every possible combination when there are multiple options. For instance, there is a webservice that takes in a request with multiple options:

    optionColor: (possible option is blue, red, green)
    optionNumber: (possible option is 1, 2, 3, 4, 5)
    optionDay (possible option is monday, tuesday, wednesday, thursday, friday, saturday, sunday)

    So in the request, I could send
    <optionColor>blue</optionColor>
    <optionNumber>2</optionNumber>
    <optionDay>tuesday</optionDay>

    Above is one possible combination. Now I'd like to programmatically code it in a way that I could send every possible combination request. I think it may require permutation or something like that. Any one have an idea? Thanks.

  2. #2
    Loquacious User Shaggy Hiker's Avatar
    Join Date
    Aug 02
    Location
    Idaho
    Posts
    20,566

    Re: how to code to do every possible combination?

    Is the real situation as small as the example? The reason I ask is because you are, indeed, talking about permutations, and the number of possible combinations gets really large really fast. Furthermore, since it is a webservice, the time taken for each test would be significantly non-zero. If each test took one second, the example you have shown is already getting big.

    The permutations could be done by nesting three loops. The outer loop runs through the colors, the next loop through the numbers, and the inner loop through the days of the week.
    My usual boring signature: Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •