Comments on Efficient censorship
Post
Efficient censorship
You are a low-level censor working for the Ministry of Media Accuracy. Part of your job is to make sure that certain words don't appear in publications. Every morning you get a fresh stack of next week's newspapers and its your job to comb through them and fix any of the words that were mistakenly included. A naive censor might simply remove the entire word completely, but you know that if you remove part of the word that still prevents the word from appearing in print. So for you it is a point of pride to remove as little of the offending word as possible while still ensuring it does not appear in print.
Task
Given strings $X$ and $Y$ output the longest substring of $X$ which does not contain $Y$ as a contiguous substring
This is code-golf so the goal is to minimize the size of your source code as measured in bytes.
Test cases
For each input output pair a possible correct output is given, your output should always be the same length, but it is not necessary to reproduce these outputs exactly.
chat, cat -> chat
escathe, cat -> esathe
homology, o -> hmlgy
ccatt, cat -> cctt
aababbabab, abab -> aaabbbab
ababab, abab -> abbab
aaaaaaaa, aaa -> aa
Japt `-h`, 7 bytes à ñÊ …
1y ago
Haskell + hgl, 14 bytes ``` …
1y ago
Vyxal, 44 bitsv2, 5.5 bytes …
1y ago
[Python 3], 102 bytes d …
1y ago
1 comment thread