I have trouble solving this exercise:
Two kids are playing a game. One kid makes up up a string s from small letters only and then removes all letters ‘a’ from it - string t. Next: merges both strings together into one s+t string. I.e. ‘car’ —> ‘carcr’. Then shows the string s+t to the second kid that is supposed to guess the original string s. Sometimes first kid tries to fool the other and string t is not just string s without letters ‘a’. I.e. when the second kid sees string ‘carbm’ he is sure that the first one is trying to trick him.
Write a programme that checks if the string given was made by merging strings s and t, where string t is equal to string s with all letters ‘a’ removed.
I have absolutely no idea how I should solve this exercise. I think I could deal with the first case by counting consonants and then slice the string somewhere (?), but those ‘fooling tries’ run me crazy.
I would be thankful if anyone could help me with this exercise using either Python or C++.
While we are primarily here to help people with their Free Code Camp progress, we are open to people on other paths, too.
With your current questions, we don’t have enough context to know what you already know or don’t know, so it is impossible to guide you without just telling you the answer (which we won’t do).
It is pretty typical on here for people to share a codepen / repl.it / jsfiddle example of what they have tried so that anyone helping has more of an idea of what help is actually helpful.
Please provide some example of what you’ve tried and I’m sure you’ll get more help.
One possible solution would be to take the resulting string (test[0:n]), create a new string using the rules and see if it is equal to the input string.