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 Build a replacement ball in regex.

In this challenge you will take a number $n$ and a string $X$ of length $\geq n$, and produce a regular expression which matches all strings that are withing $n$ character substitutions of $X$. Sp...

3 answers  ·  posted 11mo ago by WheatWizard‭  ·  last activity 11mo ago by WheatWizard‭

#2: Post edited by user avatar WheatWizard‭ · 2023-06-20T19:09:10Z (11 months ago)
  • In this challenge you will take a number $n$ and a string $X$ of length $\geq n$, and produce a regular expression which matches all strings that are withing $n$ character substitutions of $X$.
  • Specifically you will take $X$ and $n$ and ouptut all the ways to replace exactly $n$ characters with the regex wildcard `.`, separated by the regex or symbol `|`. So for `bar` and 2 as an input a valid output would be:
  • ```regex
  • ..r|.a.|b..
  • ```
  • Order doesn't matter, but each replacement should appear exactly once, and no additional symbols should appear. Other regular expressions may perform the same task, but your output should meet the specifications above.
  • This is code-golf, the goal is to minimize the size of your source code as measured in bytes.
  • ## Test cases
  • ```text
  • o, 1 -> .
  • at, 1 -> .t|a.
  • moon, 1 -> .oon|m.on|mo.n|moo.
  • at, 2 -> ..
  • bar, 2 -> ..r|.a.|b..
  • test, 2 -> ..st|.e.t|.es.|t..t|t.s.|te..
  • case, 2 -> ..se|.a.e|.as.|c..e|c.s.|ca..
  • test, 3 -> ...t|..s.|.e..|t...
  • ```
  • In this challenge you will take a number $n$ and a string $X$ of length $\geq n$, and produce a regular expression which matches all strings that are withing $n$ character substitutions of $X$.
  • Specifically you will take $X$ and $n$ and ouptut all the ways to replace exactly $n$ characters with the regex wildcard `.`, separated by the regex or symbol `|`. So for `bar` and 2 as an input a valid output would be:
  • ```regex
  • ..r|.a.|b..
  • ```
  • Order doesn't matter, but each replacement should appear exactly once, and no additional symbols should appear. Other regular expressions may perform the same task, but your output should meet the specifications above.
  • You can assume the input will consist only of the alphanumeric characters `a-zA-Z0-9`.
  • This is code-golf, the goal is to minimize the size of your source code as measured in bytes.
  • ## Test cases
  • ```text
  • o, 1 -> .
  • at, 1 -> .t|a.
  • moon, 1 -> .oon|m.on|mo.n|moo.
  • at, 2 -> ..
  • bar, 2 -> ..r|.a.|b..
  • test, 2 -> ..st|.e.t|.es.|t..t|t.s.|te..
  • case, 2 -> ..se|.a.e|.as.|c..e|c.s.|ca..
  • test, 3 -> ...t|..s.|.e..|t...
  • ```
#1: Initial revision by user avatar WheatWizard‭ · 2023-06-20T14:48:24Z (11 months ago)
Build a replacement ball in regex.
In this challenge you will take a number $n$ and a string $X$ of length $\geq n$, and produce a regular expression which matches all strings that are withing $n$ character substitutions of $X$.

Specifically you will take $X$ and $n$ and ouptut all the ways to replace exactly $n$ characters with the regex wildcard `.`, separated by the regex or symbol `|`. So for `bar` and 2 as an input a valid output would be:

```regex
..r|.a.|b..
```

Order doesn't matter, but each replacement should appear exactly once, and no additional symbols should appear. Other regular expressions may perform the same task, but your output should meet the specifications above.

This is code-golf, the goal is to minimize the size of your source code as measured in bytes.

## Test cases

```text
o, 1 -> .
at, 1 -> .t|a.
moon, 1 -> .oon|m.on|mo.n|moo.
at, 2 -> ..
bar, 2 -> ..r|.a.|b..
test, 2 -> ..st|.e.t|.es.|t..t|t.s.|te..
case, 2 -> ..se|.a.e|.as.|c..e|c.s.|ca..
test, 3 -> ...t|..s.|.e..|t...
```