Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

66%
+2 −0
Challenges Efficient censorship

Python 3, 102 bytes def f(x,y): a=[x] for x in a: if y not in x:return x for i in range(len(x)+1):a+=[x[:i]+x[i+1:]] Try it online! Not exactly the most efficient, but it works. Ju...

posted 1y ago by hyper-neutrino‭

Answer
#1: Initial revision by user avatar hyper-neutrino‭ · 2023-06-19T18:28:06Z (over 1 year ago)
# [Python 3], 102 bytes

<!-- language-all: lang-python -->

<pre><code>def f(x,y):
&#9;a=[x]
&#9;for x in a:
&#9;&#9;if y not in x:return x
&#9;&#9;for i in range(len(x)+1):a+=[x[:i]+x[i+1:]]
</code></pre>

[Try it online!][TIO-lj36vdpa]

[Python 3]: https://docs.python.org/3/
[TIO-lj36vdpa]: https://tio.run/##VY2xCsMwDETn@CtEJrsxoaWboV8SMiipnQhS2zguOF@fWrRLNRy6u4cUj7wGfz/Pp3XgZNGHMqLBx1BG0biQoAB5wJo15OAAHzIHxSSb36kutWCMOE3oFys362VR3U0Z7OqdwdDYlYG6mxnHk9mNvGU8xEpe@V9M5LN08sJVv@dEUap@jxtl2WpolVLnvGLWMGMWdq@62q9ZwytsYTk0BDHX4McgTjhNLBpYBf6Z31SL@AE "Python 3 – Try It Online"

Not exactly the most efficient, but it works. Just a BFS of all possible removals.