Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / [Mathematics & Code] I have a formula problem

Author
Message
nonZero
12
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 25th Mar 2014 22:18 Edited at: 26th Apr 2014 21:07
Editted -- now with 50% less ambiguity:


The important parts are bold, the rest is my usual senseless ranting...
Okay, I'm working on trying to build a very highly-optimized "word" generator. As we know, the total number of words is (charset lenght)^(word length). The biggest problem I've run into is the fact that removing repititions will require on-the-spot comparison or post-processing which both slow down the process.
So I want to figure out some form of mathematical approach.
The approach: We need to know two ranges. The first is the total number of increments (by 1) for which a pattern of more 3 (or a given number) of consecutive character repetitions will occur. Secondly, we need to know for how many imcrements will occur before the next repetition of 3 (or that given number). For example.
charset = ("0", "1") and word-length = 3. Total words:
000, 001, 010, 011, 100, 101, 110, 111
Not the best example but still. A 3-match occurs at 1 and again at 8.
Now usually a program would compare word[0], word[1] and word[2] for a match of 3 each loop iteration. That's a serious bottleneck (and post-processing the list is no better). You could use multi-threading and have a worker-thread run through the list while it is being created, but we are still losing precious computational power generating those unwanted entries in the first place. So what if we knew that it took exactly n iterations before we reached the first set with no 3-match patterns? What if we knew just how many until the next barrage of them? We could be talking serious word-generation power! Alas, I searched but could not find. My own thoughts were, "Well we have to work backwards, from the right side of the word since the left changes per iteration... hmm, if we just-- **BRAIN BSOD: Your brain encountered an error and has to restart. We apologize for the inconvenience. Please let us know by sending the crash report after restarting. We respect your privacy**" and that was me done.
I figured out one thing just now: we need to calculate the width each char adds to a pattern. In the example above it was the full length of the word-total, but, if my calculations are correct, it's (char position in set)^(word length). I haven't confirmed this 100% but will edit the OP with any findings.


You're a bad man!
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 25th Mar 2014 23:34
It sounds like a task for F# rather than C/C++. It has formulas for repetitions, permutations, combinations and their inverse too.

It's way beyond my capability, but it's what the language is designed for. And it integrates with Visual Studio.

nonZero
12
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 26th Mar 2014 07:20
Thanks, I'll look into it. My project is in C but I'm sure if I have to go this route, I can make them commubicate.


You're a bad man!
nonZero
12
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 25th Apr 2014 20:29
Utterly shameless buuuuump now that Neuro's back.


You're a bad man!
Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 26th Apr 2014 02:14
I don't get it. My interpretation: you want a function that takes a string "s", integers n, x, and y, such that after x iterations of this function s (calculating s=f(s,x,y,n)?) you get n repetitions?? Or something?

My only experience with pattern seeking is finding the patterns in this:


and I didn't do it a smart way. I just looped through it and used counters and what-not. It was really disgusting to write!

But I was able to do magical things with it!:
(automatically finding repeating patterns, pulling out the interesting repeating structures, colliding them, and then identifying their collisions :3)


"I <3 u 2 bbz" - Dark Frager
nonZero
12
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 26th Apr 2014 21:05
Thanks for the reply. I realise I may have come across a tad confusing, I get caught up in things and lose my wording. Here's what I meant (and shall edit into the OP):
The important parts are bold, the rest is my usual senseless ranting...
Okay, I'm working on trying to build a very highly-optimized "word" generator. As we know, the total number of words is (charset lenght)^(word length). The biggest problem I've run into is the fact that removing repititions will require on-the-spot comparison or post-processing which both slow down the process.
So I want to figure out some form of mathematical approach.
The approach: We need to know two ranges. The first is the total number of increments (by 1) for which a pattern of more 3 (or a given number) of consecutive character repetitions will occur. Secondly, we need to know for how many imcrements will occur before the next repetition of 3 (or that given number). For example.
charset = ("0", "1") and word-length = 3. Total words:
000, 001, 010, 011, 100, 101, 110, 111
Not the best example but still. A 3-match occurs at 1 and again at 8.
Now usually a program would compare word[0], word[1] and word[2] for a match of 3 each loop iteration. That's a serious bottleneck (and post-processing the list is no better). You could use multi-threading and have a worker-thread run through the list while it is being created, but we are still losing precious computational power generating those unwanted entries in the first place. So what if we knew that it took exactly n iterations before we reached the first set with no 3-match patterns? What if we knew just how many until the next barrage of them? We could be talking serious word-generation power! Alas, I searched but could not find. My own thoughts were, "Well we have to work backwards, from the right side of the word since the left changes per iteration... hmm, if we just-- **BRAIN BSOD: Your brain encountered an error and has to restart. We apologize for the inconvenience. Please let us know by sending the crash report after restarting. We respect your privacy**" and that was me done.
I figured out one thing just now: we need to calculate the width each char adds to a pattern. In the example above it was the full length of the word-total, but, if my calculations are correct, it's (char position in set)^(word length). I haven't confirmed this 100% but will edit the OP with any findings.


You're a bad man!

Login to post a reply

Server time is: 2024-04-27 16:58:08
Your offset time is: 2024-04-27 16:58:08