Skip to content

Instantly share code, notes, and snippets.

@jrunning
Created August 12, 2016 19:02
Show Gist options
  • Save jrunning/15c4867c9cbe77e3dd0f516725992354 to your computer and use it in GitHub Desktop.
Save jrunning/15c4867c9cbe77e3dd0f516725992354 to your computer and use it in GitHub Desktop.
https://repl.it/Cm9I/0 created by jrunning
fn=
->s{w=s=~/\n/
i=0
s.scan(/(..|.\n)(?=.{#{w-1}}(..|.\n))?/m).map{|a|(("%4s"%(a*"")).tr($/," ").bytes.reduce(:+)/4.0).round.chr*2}.each_slice(w/2+w%2){|l|puts l*="",l if i%2<1
i+=1}}
fn[<<END]
%%%%%%%%%%%%%
% Hello, %
% world! %
%%%%%%%%%%%%%
END
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
>>> $$>>II99######
$$>>II99######
$$##88KKGG####
$$##88KKGG####
=> nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment