1
I have the following problem, I want to know the combinations of certain letter in the string, example:
AAbA
Viraria
AAbA, AAb, Ab, bA, b
I arrived at the following code, but does not contemplate the answer, it creates combinations that should not be in the answer
def add_all_possibilities(item, nonTerminalWithEpisolon, production):
numberNonTerminal = item.count(nonTerminalWithEpisolon)
for i in range(numberNonTerminal + 1):
new_production = item.replace(nonTerminalWithEpisolon, "", i)
self._productions[production].add(new_production)
self._productions[production].add(new_production[::-1])
Where item is the string "Aaba", nonTerminalWithEpisolon is "A" which should be the combination of that letter and Production does not matter for that part of the problem
Vinicius could explain the goal and how you arrived at the desired combinations?
– Killdary Aguiar de Santana
It is an algorithm for Formal Languages, removal of Episolon, the idea is this: the A can be considered as an empty symbol or not, so you have to create all possible combinations of this.
– Vinicius Macelai