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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T02:18:56+00:00 2026-06-19T02:18:56+00:00

I am trying to make a url from a different combinations of string separated

  • 0

I am trying to make a url from a different combinations of string separated by comma so that I can use those url to execute them and get the data back.

I have simplified something like this, I have a HashSet that will contain all my strings, not A,B,C in real. I just modified it here to make it simple.

Set<String> data = new HashSet<String>();
h.add("A");
h.add("B");
h.add("C");    

for (int i = 1; i < 1000; i++) {

String pattern = generateString(data);

String url = "http://localhost:8080/service/USERID=101556000/"+pattern;

System.out.println(url);

}

/**
 * Below is the method to generate Strings.
 /
private String generateString(HashSet<String> data) {

//not sure what logic I am supposed to use here?

}

So the output should be something like this-

http://localhost:8080/service/USERID=101556000/A
http://localhost:8080/service/USERID=101556000/B
http://localhost:8080/service/USERID=101556000/C
http://localhost:8080/service/USERID=101556000/A,B,C
http://localhost:8080/service/USERID=101556000/B,C
http://localhost:8080/service/USERID=101556000/C,A

--
And other combinations

The above output can be in any random order as well. But it should be all the possible combinations. And if all the possible combinations are finished then start again.

Any suggestion how can I achieve the above problem definition?

  • 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-19T02:18:57+00:00Added an answer on June 19, 2026 at 2:18 am

    Given what is k-arrangement (http://en.wikibooks.org/wiki/Probability/Combinatorics), you are looking for the k-arrangement where k varies from 1 to D, where D is the size of the data collections.

    This means to compute – my first post I can’t post image so look at equation located at :

    In order to do it, you can make k varies, and the for each k may n varies (i.e. deal only with a sub array or data to enumerate the k-permutations). These k-permutations can be found by walking the array to the right and to the left using recursion.

    Here is a quick bootstrap that proves to enumerate whart is required :

    public class EnumUrl {
    
    private Set<String> enumeration = null;
    private List<String> data = null;
    private final String baseUrl = "http://localhost:8080/service/USERID=101556000/";
    
    public EnumUrl(List<String> d) {
        data = d;
        enumeration = new HashSet<String>(); // choose HashSet : handle duplicates in the enumeration process
    }
    
    public Set<String> getEnumeration() {
        return enumeration;
    }
    
    public static void main(String[] args) {
    
        List<String> data = new ArrayList<String>();
        data.add("A");
        data.add("B");
        data.add("C");
    
        EnumUrl enumerator = new EnumUrl(data);
    
        for (int k = 0; k < data.size(); k++) {
    
            // start from any letter in the set
            for (int i = 0; i < data.size(); i++) {
                // enumerate possible url combining what's on the right of indice i
                enumerator.enumeratePossibleUrlsToRight(data.get(i), i);
    
                // enumerate possible url combining what's on the left of indice i
                enumerator.enumeratePossibleUrlsToLeft(data.get(i), i);
            }
    
            // make a circular permutation of -1 before the new iteration over the newly combined data
            enumerator.circularPermutationOfData();
        }
    
        // display to syso
        displayUrlEnumeration(enumerator);
    }
    
    private void circularPermutationOfData() {
        String datum = data.get(0);
        for (int i = 1; i < data.size(); i++) {
            data.set(i - 1, data.get(i));
        }
        data.set(data.size() - 1, datum);
    }
    
    private static void displayUrlEnumeration(EnumUrl enumerator) {
        for (String url : enumerator.getEnumeration()) {
            System.out.println(url);
        }
    }
    
    private void enumeratePossibleUrlsToRight(String prefix, int startAt) {
        enumeration.add(baseUrl + prefix);
        if (startAt < data.size() - 1) {
            startAt++;
            for (int i = startAt; i < data.size(); i++) {
                int x = i;
                enumeratePossibleUrlsToRight(prefix + "," + data.get(x), x);
            }
        }
    }
    
    private void enumeratePossibleUrlsToLeft(String prefix, int startAt) {
        enumeration.add(baseUrl + prefix);
        if (startAt > 0) {
            startAt--;
            for (int i = startAt; i >= 0; i--) {
                int x = i;
                enumeratePossibleUrlsToLeft(prefix + "," + data.get(x), x);
            }
        }
    }
    }
    

    The program outputs for {A,B,C} :

    http://localhost:8080/service/USERID=101556000/B,C
    http://localhost:8080/service/USERID=101556000/B,A,C
    http://localhost:8080/service/USERID=101556000/B,C,A
    http://localhost:8080/service/USERID=101556000/B,A
    http://localhost:8080/service/USERID=101556000/C
    http://localhost:8080/service/USERID=101556000/B
    http://localhost:8080/service/USERID=101556000/C,B,A
    http://localhost:8080/service/USERID=101556000/A,C,B
    http://localhost:8080/service/USERID=101556000/A,C
    http://localhost:8080/service/USERID=101556000/A,B
    http://localhost:8080/service/USERID=101556000/A,B,C
    http://localhost:8080/service/USERID=101556000/A
    http://localhost:8080/service/USERID=101556000/C,B
    http://localhost:8080/service/USERID=101556000/C,A
    http://localhost:8080/service/USERID=101556000/C,A,B
    

    And for {A,B,C,D} :

    http://localhost:8080/service/USERID=101556000/B,A,D,C
    http://localhost:8080/service/USERID=101556000/C,D
    http://localhost:8080/service/USERID=101556000/A,D,C,B
    http://localhost:8080/service/USERID=101556000/A,C,D
    http://localhost:8080/service/USERID=101556000/D
    http://localhost:8080/service/USERID=101556000/C
    http://localhost:8080/service/USERID=101556000/A,C,B
    http://localhost:8080/service/USERID=101556000/B
    http://localhost:8080/service/USERID=101556000/A,B,C,D
    http://localhost:8080/service/USERID=101556000/A,B,C
    http://localhost:8080/service/USERID=101556000/D,C,B,A
    http://localhost:8080/service/USERID=101556000/C,B,A,D
    http://localhost:8080/service/USERID=101556000/A,B,D
    http://localhost:8080/service/USERID=101556000/D,B
    http://localhost:8080/service/USERID=101556000/D,C
    http://localhost:8080/service/USERID=101556000/A
    http://localhost:8080/service/USERID=101556000/D,C,A
    http://localhost:8080/service/USERID=101556000/D,C,B
    http://localhost:8080/service/USERID=101556000/C,D,A
    http://localhost:8080/service/USERID=101556000/C,D,B
    http://localhost:8080/service/USERID=101556000/D,A
    http://localhost:8080/service/USERID=101556000/A,D,C
    http://localhost:8080/service/USERID=101556000/A,D,B
    http://localhost:8080/service/USERID=101556000/C,B,D
    http://localhost:8080/service/USERID=101556000/B,A,D
    http://localhost:8080/service/USERID=101556000/B,C
    http://localhost:8080/service/USERID=101556000/B,A,C
    http://localhost:8080/service/USERID=101556000/B,C,A
    http://localhost:8080/service/USERID=101556000/B,A
    http://localhost:8080/service/USERID=101556000/B,C,D
    http://localhost:8080/service/USERID=101556000/C,B,A
    http://localhost:8080/service/USERID=101556000/A,D
    http://localhost:8080/service/USERID=101556000/D,A,B
    http://localhost:8080/service/USERID=101556000/A,C
    http://localhost:8080/service/USERID=101556000/D,A,C
    http://localhost:8080/service/USERID=101556000/B,C,D,A
    http://localhost:8080/service/USERID=101556000/A,B
    http://localhost:8080/service/USERID=101556000/B,D
    http://localhost:8080/service/USERID=101556000/C,D,A,B
    http://localhost:8080/service/USERID=101556000/D,A,B,C
    http://localhost:8080/service/USERID=101556000/D,B,A
    http://localhost:8080/service/USERID=101556000/D,B,C
    http://localhost:8080/service/USERID=101556000/B,D,A
    http://localhost:8080/service/USERID=101556000/C,B
    http://localhost:8080/service/USERID=101556000/C,A,D
    http://localhost:8080/service/USERID=101556000/C,A
    http://localhost:8080/service/USERID=101556000/B,D,C
    http://localhost:8080/service/USERID=101556000/C,A,B
    

    Which is not the exhaustive enumeration. Basically we should have:

    (my first post I can’t post image to look at equation located in my reply, I don’t have the reputation to post 2 links … #omg)

    That makes 64 combinaisons, distributed as follows:

    • 4 combinaisons of 1 element (k=1)
    • 12 combinaisons of 12 element (k=2)
    • 24 combinaisons of 24 element (k=3)
    • 24 combinaisons of 24 element (k=4)

    You can see that my program is OK for k=1, k=2, and k=3. But there are not 24 combinaisons for k=4. In order to complete the program, you will need to iterate also on other type of shuffling the data than circular permutation. Actually when k=4, circular permutation does not generate for instance ADBC as input data (hence DBCA cannot be generated by my implementation for instance). In this case, you will want to enumerate all possible data input array with n elements in all possible order. This is a special case of k-permutation, where k=n, and therefore leads to finding the n! permutation. We can achieve this by calling the EnumUrl method for each of the n! possible permutation.

    For this, you should update EnumUrl enumerator = new EnumUrl(data); accordingly, but I guess I am letting some work for you to make 🙂

    HTH

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

Sidebar

Related Questions

I am trying to make a bookmarklet that when clicked will check the URL
I am trying to create a validation that checks to make sure a domain/url
I am trying to make a proxy server that gets a page from www.xxx.com
I'm trying to make a calculator that will take inputs from users and estimate
I am trying to make clean url with htaccess I have a profile.php page
I'm trying to make a clean url for a blog on a dynamic website,
I'm trying to make a simple HTTP post a endpoint with ONLY url arguments.
I'm trying make an entity with doctrine that has three associations with other entities
Trying to make this jQuery filter that uses .find case-insensitive. For example, when the
I need to pass a url string from the view to the controller, a

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.