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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:52:23+00:00 2026-05-24T18:52:23+00:00

I’m thinking about an algorithm that will create X most unique concatenations of Y

  • 0

I’m thinking about an algorithm that will create X most unique concatenations of Y parts, where each part can be one of several items. For example 3 parts:

part #1: 0,1,2
part #2: a,b,c
part #3: x,y,z

And the (random, one case of some possibilities) result of 5 concatenations:

0ax
1by
2cz
0bz (note that '0by' would be "less unique " than '0bz' because 'by' already was)
2ay (note that 'a' didn't after '2' jet, and 'y' didn't after 'a' jet)

Simple BAD results for next concatenation:

1cy ('c' wasn't after 1, 'y' wasn't after 'c', BUT '1'-'y' already was as first-last 

Simple GOOD next result would be:

0cy ('c' wasn't after '0', 'y' wasn't after 'c', and '0'-'y' wasn't as first-last part)
1az
1cx

I know that this solution limit possible results, but when all full unique possibilities will gone, algorithm should continue and try to keep most avaible uniqueness (repeating as few as possible).

Consider real example:

Boy/Girl/Martin
bought/stole/get
bottle/milk/water

And I want results like:

Boy get milk
Martin stole bottle
Girl bought water
Boy bought bottle (not water, because of 'bought+water' and not milk, because of 'Boy+milk')

Maybe start with a tree of all combinations, but how to select most unique trees first?

Edit: According to this sample data, we can see, that creation of fully unique results for 4 words * 3 possibilities, provide us only 3 results:

Martin stole a bootle
Boy bought an milk
He get hard water

But, there can be more results requested. So, 4. result should be most-available-uniqueness like Martin bought hard milk, not Martin stole a water

Edit: Some start for a solution ?
Imagine each part as a barrel, wich can be rotated, and last item goes as first when rotates down, first goes as last when rotating up. Now, set barells like this:

Martin|stole |a   |bootle
Boy   |bought|an  |milk
He    |get   |hard|water

Now, write sentences as We see, and rotate first barell UP once, second twice, third three and so on. We get sentences (note that third barell did one full rotation):

Boy   |get   |a   |milk
He    |stole |an  |water
Martin|bought|hard|bootle 

And we get next solutions. We can do process one more time to get more solutions:

He    |bought|a   |water
Martin|get   |an  |bootle
Boy   |stole |hard|milk 

The problem is that first barrel will be connected with last, because rotating parallel.
I’m wondering if that will be more uniqe if i rotate last barrel one more time in last solution (but the i provide other connections like an-water – but this will be repeated only 2 times, not 3 times like now). Don’t know that "barrels" are good way ofthinking here.

I think that we should first found a definition for uniqueness

For example, what is changing uniqueness to drop ? If we use word that was already used ? Do repeating 2 words close to each other is less uniqe that repeating a word in some gap of other words ? So, this problem can be subjective.

But I think that in lot of sequences, each word should be used similar times (like selecting word randomly and removing from a set, and after getting all words refresh all options that they can be obtained next time) – this is easy to do.

But, even if we get each words similar number od times, we should do something to do-not-repeat-connections between words. I think, that more uniqe is repeating words far from each other, not next to each other.

  • 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-24T18:52:25+00:00Added an answer on May 24, 2026 at 6:52 pm

    Anytime you need a new concatenation, just generate a completely random one, calculate it’s fitness, and then either accept that concatenation or reject it (probabilistically, that is).

    const C = 1.0
    
    function CreateGoodConcatenation()
    {
      for (rejectionCount = 0; ; rejectionCount++)
      {
        candidate = CreateRandomConcatination()
        fitness = CalculateFitness(candidate) // returns 0 < fitness <= 1
        r = GetRand(zero to one)
        adjusted_r = Math.pow(r, C * rejectionCount + 1)  // bias toward acceptability as rejectionCount increases
        if (adjusted_r < fitness)
        {
          return candidate
        }
      }
    }
    

    CalculateFitness should never return zero. If it does, you might find yourself in an infinite loop.

    As you increase C, less ideal concatenations are accepted more readily.
    As you decrease C, you face increased iterations for each call to CreateGoodConcatenation (plus less entropy in the result)

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
I am reading a book about Javascript and jQuery and using one of the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into

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.