#Divide strings into "all" the possible combinations.

9 messages · Page 1 of 1 (latest)

green ridge
#

Do not stress over this, do it if you find it enjoyable. I think it is a fun problem.

Let's say I have a random string "abv". It can have any text characters instead of "a", "b" and "v", and it can be any length. I want to divide it into many combinations of strings like this below.

I also want to save "spaces" (that something is there, the string continues) and "end" (that there are no more characters before/after it, the string ends there). In this case - I represent "space" with "0" and "end" with "-".

On the left is the same thing but with serial numbers, just for the extra comparison in order to explain what I really want. The first row in every section, marked with "#" is just for the explanation, it shows the string the code is working on in the (current) section.

Worry not about the performance.

So, because of "ends", represented with "-", I would actually have exactly the same thing but with two more characters on each end, "abv" would actually be "-abv-", so it is many many more strings. Therefore - a string "abv" would be considered as "-abv-", which is of length 5, somewhat.

Text characters can repeat but they all sort of have own spot.

Strings that are repeating I do not want to be saved again, but I want to add a counter to each string that counts how many times it was gotten (repeated), I think I could do the counter myself, but for those who like even deeper problems - here you go.

For example, Working with this "abv", first working with "a" gives two strings: "0" and "a", next, working with just "b" gives again two strings: "0" and "b", in this case, "space" (or "0") is repeating, so we just increase the counter for it by one instead of saving it as a string by itself, so we get: "0=2", "a=1", "b=1", so eventually, in this case there will be strings saved as: "-ab", "abv-" and so, see the chart below of all possible combinations with the string "abv".

#

Be aware that I am a human and so that I might made a mistake, especially in the chart, it (the mistake) might change everything, but probably not, I think I got exactly what I want.

The chart example is considered spam by bots and I can not post it, here is the picture.

autumn cedar
#

Are you asking for help or posting a challenge? Either way it could be a bit clearer.

autumn cedar
#

Your problem statement is not clear at all. You may want to reword it.

green ridge
autumn cedar
#

Let me try again: please explain your problem again. I read it twice and I do not understand what you are trying to do.

green ridge
#

I wrote this as the explanation, what more can I add? More examples?

autumn cedar
#

Write it again in simpler language and with examples. Also explain what spaces and ends are. Usually a space is just another character and ends are implied by the length of the string.