One liner quiz!


My quiz suggestion is to generate such a string in Ruby:

| |

Some kind of ascii art, with a frame where we can see a random string
in the upper border and its reverse counterpart in the bottom border.

But: the solution must be a one-liner! No temporary variables, etc.

(One can use such a string to set in mp3 or video files comment
metadata, to change its CRC, or promoting their website.)

puts “±-==#%s==–+\n| %s |\n±-==%s==–+” %

Not bad, but the random text part isn’t random in fact, it is a function
of the website url ARGV[0]. It should be random, and must be changing at
every invocation of the command, so one can change the CRC of a mp3 or
video file by simply adding this small piece of ASCII art as comment
metadata to the file.

Such kind of temporary variables like .map{|z| …} are allowed.

Thx, my solution was:

#{ARGV[0]} |\n")

“±-==%s==–+\n| %s |\n±-==%s==–+”%[x,ARGV[0],x.reverse]}

sample output:

| |


| |

You might be interested in