Ruby - N=45
Let Ruby be Ruby and embrace the wrap-around penalty.N=45
for c in '!'..'~' do putc c end
for c in '!'..'~' do putc ('~'.ord+'!'.ord-c.ord).chr end
or
('!'..'~').select { |c| putc c }
('!'..'~').select { |c| putc ('~'.ord+'!'.ord-c.ord).chr }
(The select isn't natural, but each has an 'a' in it.)
Old:
N=72 {straight-line scoring} <- 72 ('.'-'u')
N=68 {wrap-around scoring} <- 29 ('!'-'=') + 36 ('['-'~') + 3
format = 67.chr
format << 42.chr
a = []
for i in 33..126 do a << i end
t = a.dup
for i in 33..126 do a << t.pop end
puts a.pack format
There's some flailing in here to avoid the 'v' in "reverse" that hurts the wrap-around score. I left it in because I'm fond of the pack("C*") hack.