Created
September 7, 2021 11:49
-
-
Save andrepiske/91d7c9506ec8f4f0c2265f54c2071158 to your computer and use it in GitHub Desktop.
Unlolify (ASCII)
This file contains hidden or 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
| def unlolify(n);s=n.to_s(2);s.rjust((s.length/8.0).ceil*8,'0').split('').each_slice(8).to_a.map{|x|x.join.to_i(2).chr}.join;end | |
| def lolify(s);s.split('').map{|x|x.ord.to_s(2).rjust(8,'0')}.join;end | |
| # > unlolify(lolify('Hello, world!').to_i(2)) | |
| # => "Hello, world!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment