1
\$\begingroup\$

I would like to convert ASCII art to something that takes less bytes. I have string like this:

my $string = '                ██   ████   █';

And I would convert this to something like this:

print "█" x 1."█" x 1."█" x 1"█" x 1"█" x 1;

So I would write this in one line and convert to using x operator. How can achieve this?

\$\endgroup\$
8
  • 1
    \$\begingroup\$ Welcome to PPCG! I have added the code-golf tag since questions here require a winning criteria. Generally questions here allow any language to compete (you can always say you are keen to see Perl solutions), so I'd suggest that (an alternative would be to fit this to the tips category but I think it fits better as a normal golf question). EDIT: I see Shaggy also added tips now - let's see where we go :) \$\endgroup\$ Apr 30, 2018 at 21:11
  • \$\begingroup\$ Don't you mean print " " x 16."█" x 2." " x 3."█" x 4." " x 3."█" x 1;? \$\endgroup\$
    – Adám
    Apr 30, 2018 at 21:33
  • \$\begingroup\$ @JonathanAllan even if it was intended as a challenge, it's horribly underspecified. \$\endgroup\$
    – Nissa
    Apr 30, 2018 at 21:42
  • \$\begingroup\$ @StephenLeppik I don't think it was and agree. It could probably be made into one though! \$\endgroup\$ Apr 30, 2018 at 21:50
  • \$\begingroup\$ @JonathanAllan Isn't it just asking for run-length encoding? \$\endgroup\$
    – Adám
    Apr 30, 2018 at 22:40

0

Browse other questions tagged or ask your own question.