Created
June 19, 2017 16:35
-
-
Save jrunning/2e6667175354a8ba7322918a384ec372 to your computer and use it in GitHub Desktop.
decimal↔unary in GNU sed
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
#!/usr/bin/env sed -rf | |
# 2017 Jordan Running <[email protected]> | |
s/^0$// | |
tZ | |
s/$/!:9876543210/ | |
: | |
s/0!/!9/ | |
t | |
s/(.)!(.*):(.*\1)(.)/\4\2:\3\4/ | |
s/(.*):/;\1!:/ | |
s/;0/;/ | |
/;!/!b | |
s/!.*// | |
:Z |
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
#!/usr/bin/env sed -rf | |
# 2017 Jordan Running <[email protected]> | |
s/$/0!:0123456789/ | |
: | |
/;/!bZ | |
s/9!/!0/ | |
t | |
s/;!/;1/ | |
s/(.)!(.*):(.*\1)(.)/\4\2:\3\4/ | |
s/;(.*):/\1!:/ | |
b | |
:Z | |
s/!.*// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment