Skip to content

Instantly share code, notes, and snippets.

@JoshCheek
Last active August 16, 2016 01:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoshCheek/b543a35c09767c14eb6abc7f49db8864 to your computer and use it in GitHub Desktop.
Save JoshCheek/b543a35c09767c14eb6abc7f49db8864 to your computer and use it in GitHub Desktop.
Obfuscated printing of "wat"
# ruby -e '$.-=~$.;$_=-~$.<<-~-~-~$.;$:<<$_|=$_<<$.;$_|=$_>>$.;$:.<<(-~$.<<$.);$>.<<$/[$....$.]<<$_+$:[-$.]+-~$.+$.<<$:[~$.]+$.<<$_+$:[-$.]<<$/'
# ruby -e '$.-=~$.;$_=-~$.<<-~-~-~$.;$:<<$_|=$_<<$.;$_|=$_>>$.;$:<<(-~$.<<$.);$>.<<$/[$....$.]<<$_+$:[-$.]+-~$.+$.<<$:[~$.]+$.<<$_+$:[-$.]<<$/'
# ruby -e '$.-=~$.;$_=-~$.<<-~-~-~$.;$:<<$_|=$_<<$.;$_|=$_>>$.;$:<<-~$.*-~$.;$>.<<$/[$....$.]<<$_+$:[-$.]+-~$.+$.<<$:[~$.]+$.<<$_+$:[-$.]<<$/'
# ruby -e '$.-=~$.;$;=-~$.<<-~-~$.;$;|=$;<<$.;$:<<$;--$;;$;|=$;--$;;$:<<-~$.-~$.;$>.<<$/[$....$.]<<-~$;--$:[-$.]-~$.<<-~$:[~$.]<<-~$;-~-~$.<<$/'
# ruby -e '$.-=~$.;$;=-~$.<<-~-~$.;$;|=$;<<$.;$>.<<$/[$....$.]<<-~[$;|$;--$;][~-$.]-~$.-~$.-~$.<<-~$;--$;<<-~[$;|$;--$;][~-$.]-~-~$.<<$/'
# ruby -e '$;=$.-=~-~$.;$.<<=$.;$;=--~-$.<<-~-~$;;$>.<<$/[$.-$....$.-$.]<<$;--~-$.<<-~$;-$.-$.<<-~-~-~-~$;<<$/'
require 'stringio'
$stdout = StringIO.new
eval(code=DATA.read.strip)
$stdout.string # => "wat\n"
code.chars.length + "ruby -e''".length # => 108
code.chars.uniq # => ["$", ";", "=", ".", "-", "~", "<", ">", "/", "[", "]"]
.length # => 11
__END__
$;=$.-=~-~$.;$.<<=$.;$;=--~-$.<<-~-~$;;$>.<<$/[$.-$....$.-$.]<<$;--~-$.<<-~$;-$.-$.<<-~-~-~-~$;<<$/
# Tweeted as https://twitter.com/josh_cheek/status/765261304231628800
ruby -e '$.-=~$.;$_=-~$.<<-~-~-~$.;$:<<$_|=$_<<$.;$_|=$_>>$.;$:<<(-~$.<<$.);$><<(""<<$_+$:[-$.]+-~$.+$.<<$:[~$.]+$.<<$_+$:[-$.]<<$/)'
# Since improved to this
# * removed these chars: |_():+"
# * added 4 periods in a row
# * confusing semicolons
# * If there was a way to get an empty string, I could also get rid of the brackets
ruby -e '$;=$.-=~-~$.;$.<<=$.;$;=--~-$.<<-~-~$;;$>.<<$/[$.-$....$.-$.]<<$;--~-$.<<-~$;-$.-$.<<-~-~-~-~$;<<$/'
$\=$/[$....$.]
$.-=~$.
$_=-~$.<<-~-~-~$.
$:<<$_|=$_<<$.
$_|=$_>>$.
$:<<-~$.*-~$.
$>.<<$\<<$_+$:[-$.]-~$.+$.<<$:[~$.]+$.<<$_+$:[-$.]<<$/
# >> wat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment