Post History
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...
#2: Post edited
- 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
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... ```