-
-
Save jan-g/11047aaf50d0ac3b4e40bb76dedbf2e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
munge() { | |
sed -u -E -e 's/\b7\w{25,34}(\s|$)/7YWHMfk9JZe0LM0g1ZauHuiSxhI\1/g' | |
} | |
munge | | |
socat - TCP:chat.protohackers.com:16963 | | |
munge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
socat TCP-LISTEN:12345,fork,reuseaddr EXEC:./downstream |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sed doesn't do lookbehind/lookahead. | |
This works because the tests don't try foo-7abcdefghijklmnopqrstuvwxyz; using capture groups around the expression | |
and backrefs in the replacement doesn't work if you have two bogusCoin addresses separated by a single space. | |
Replacing the implementation of munge with some other stdio pipe that does the business is left as an exercise to the reader. |
To anyone scratching their head: this relates to https://protohackers.com/ which is a harmless bit of fun.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thinking a little more about it, you can use capture groups and backrefs in a sneaky fashion to get something closer to "correct":