Created
November 10, 2018 05:39
-
-
Save vznvzn/1cd4868ced0b92a1ff89061e2b771699 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
def fmt(l, f) | |
w = l.max_by { |x| x.length }.length | |
f.puts("set colors classic; \\") | |
f.puts("plot \\") | |
f.puts("[0:#{w}][0:#{l.size - 1}] '-' matrix with image title ''") | |
l.each_with_index \ | |
{ | |
|z, i| | |
c = w - z.length | |
z[z.length...w] = '0' * c | |
f.puts(z.split('').join(' ')) | |
} | |
f.puts("eof") | |
f.puts("eof") | |
f.puts("pause -1;") | |
end | |
f = File.open(fn = "gnuplot1.cmd", 'w') | |
f.puts("set palette negative grayscale; unset colorbox;") | |
l = (f1 = File.open('out1.txt')).readlines.map { |x| x.strip } | |
f1.close | |
fmt(l, f) | |
l = l.map \ | |
{ | |
|x| | |
n = x.reverse.to_i(2) * 2 - 1 | |
raise if (n % 3 != 0) | |
(n / 3).to_s(2).reverse | |
} | |
fmt(l, f) | |
f.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment