I'm currently at a roadblock of sorts and could use some help.
I would like to return all possible combinations for a string while maintaining the proper order of everything and avoiding duplicates. The reason for this? I'd like to make answers more flexible by allowing a mix of kana and kanji. As such, I require all possible combinations for comparison against the user's answer.
This is the current syntax of the function: (located here)
The text within curly braces is the text that will be replaced by the alternative text in the second argument, I'll refer to these simply as replacements. HOWEVER, the alternate text should ONLY replace the same index. That is:
月曜日 can only be replaced with げつようび
水曜日 can only be replaced with すいようび
and so on...
To give a simple example of what I'd like to achieve. Say I have the following:
Genki.getAlts('...{A}...{B}...', '1|2', true);
I'd like it to return all combinations, such as below.
The current implementation works well with 2-7 given replacements, but when given more than 8, the total combo coverage begins to drop. The total amount of combinations can be calculated using this formula: Math.pow(2, 8), which would return "256" combinations for 8 replacements, but currently getAlts() is only returning 234 combos, which means we're missing 22, only giving us 91% combo coverage.
So that is where I'm currently stuck. You can review the current code via the links below. (and yes, it's rather hackish) Being self-taught I tried my best to get as many combos as possible, but I'm afraid that my skill with mathematics isn't that good. I'm sure there's a much simpler way of going about this and I'm just overthinking it.
As an example of the current algorithm's failure, open your console, and you should see a warning for the last problem, saying something along the lines of:
234/256 (91.40625% combo coverage for 8 replacements; 22 missing combos
Is there any possible and simplistic way of returning all the combinations for a string regardless of how many replacements are specified?
If you're able to help with this, or possibly know of an existing algorithm or framework for achieving this, please let me know. Also let me know if you require any further information. I've given myself quite the headache with this, so thank you in advance for any help.
P.S.
This task is not urgent, so there's no need to rush. As things are, the algorithm works fine for 2-7 replacements, with very few problems reaching or going above this threshold.
Hello!
I'm currently at a roadblock of sorts and could use some help.
I would like to return all possible combinations for a string while maintaining the proper order of everything and avoiding duplicates. The reason for this? I'd like to make answers more flexible by allowing a mix of kana and kanji. As such, I require all possible combinations for comparison against the user's answer.
This is the current syntax of the function: (located here)
The text within curly braces is the text that will be replaced by the alternative text in the second argument, I'll refer to these simply as replacements. HOWEVER, the alternate text should ONLY replace the same index. That is:
To give a simple example of what I'd like to achieve. Say I have the following:
I'd like it to return all combinations, such as below.
The current implementation works well with 2-7 given replacements, but when given more than 8, the total combo coverage begins to drop. The total amount of combinations can be calculated using this formula:
Math.pow(2, 8)
, which would return "256" combinations for 8 replacements, but currently getAlts() is only returning 234 combos, which means we're missing 22, only giving us 91% combo coverage.So that is where I'm currently stuck. You can review the current code via the links below. (and yes, it's rather hackish) Being self-taught I tried my best to get as many combos as possible, but I'm afraid that my skill with mathematics isn't that good. I'm sure there's a much simpler way of going about this and I'm just overthinking it.
As an example of the current algorithm's failure, open your console, and you should see a warning for the last problem, saying something along the lines of:
Is there any possible and simplistic way of returning all the combinations for a string regardless of how many replacements are specified?
If you're able to help with this, or possibly know of an existing algorithm or framework for achieving this, please let me know. Also let me know if you require any further information. I've given myself quite the headache with this, so thank you in advance for any help.
P.S. This task is not urgent, so there's no need to rush. As things are, the algorithm works fine for 2-7 replacements, with very few problems reaching or going above this threshold.