← Back to topics
Topic

MoreStrings

A
Al3kSaNdaR
Can someone explain me this test case? I can't understand why should I output no , and my solution passes 8/10 test cases. :-(

Sample Input:

east west wesseatt

Sample Output:

no
t
tgudlek
Who could you get "east" by erasing some letters from "wesseatt"?
A
Al3kSaNdaR
Aham, i get it now. I didn't figured out the text of the task. Thanks. :)
f
frank44
I'm trying to solve it recursively, by trying out every possible way of dividing the third string. However I'm getting 7/10. I can't seem to find whats wrong with my code. Could someone give me a tricky case? Maybe then I could debug it.
f
frank44
wow... I found my error. I was reading info from an input file. I had forgotten to remove it. lol. Apparently my program always returned "no".
i
iggy91
Dividing? Hm... I used recursive aproach also, with three integer parameters (i,j,k) which represented current positions in every one of given three strings.

If you get to the end of all three strings, then return "yes".
If you get to the end of the first two strings, but not third, return "no".
If current character of first string is equal to current character of third string, check whether rek(i+1,j,k+1) returns "yes" and if it is, return it further.

Else check if current character of second string is equal to current character of third string and return rek(i,j+1,k+1).

From main program you should call rek(0,0,0).

This should get the job done.
i
iggy91
Oh sorry, you answered in the meantime, while I was writing my post. Anyway, it may be helpful to someone else.. Cheers! ;)
f
frank44
Yep, that's almost exactly how I solve it.
i
iggy91
Yea, I saw that...
g
gigac
Hey iggy91...
Can you help me and look in my code and tell me what's wrong with it.
I'm not so good with recursions but I want to learn about it.
I want to solve this task just like you said.
Thanks :) :)
p
picsel
You can't read 3 strings in the same line with 3 ReadLn.
g
gigac
It's the same :S
Something is wrong with the function... :S :S
g
gigac
Crap !
I always fail on three of the test cases. Please tell me what to do ! :@ I'm going crazy!