How to efficiently remove every occurrence of one string inside another
+1
−8
I have two strings and want to remove every occurrence of the second string inside the first one starting from the beginning of the first string and as if each occurrence was removed immediately. I would like to do so in C in a time-efficient way, i.e. probably with the lowest number of comparisons and include/copy actions.
1 answer
+1
−2
I've accidentally disabled my account hence I'm answering the questions that I've answered before again. Adding on to this, I feel like adding a comment, please do bear in mind that this code isn't necessarily working.
Solution:
myProgram = do {
putStrLn "Enter three sides: ";
str<-getLine;
putStr "RightAngle: ";
print (snd(head (classify (head (strtok str)) (strtok str!!1) (strtok str!!2))));
putStr "Isosceles: ";
print (snd (classify (head (strtok str)) (strtok str!!1) (strtok str!!2)!!1));
putStr "Equilateral: ";
print (snd(classify (head (strtok str)) (strtok str!!1) (strtok str!!2)!!2));
putStr "Scalene: ";
print (snd(classify (head (strtok str)) (strtok str!!1) (strtok str!!2)!!3));
putStr "End"}```
5 comment threads