1
\$\begingroup\$

Your task is to write a program/function to scale up an image (list of strings) by a factor of n.

Specs

  • You will receive two inputs: an image, and a positive integer.
  • The image will only contain ASCII printable characters (U+0020-U+007F).

Scoring

This is . Shortest solution in bytes wins.

Testcases

Testcase 1

abc
xyz

2

aabbcc
aabbcc
xxyyzz
xxyyzz

Testcase 2

|_|

3

|||___|||
|||___|||
|||___|||
\$\endgroup\$
  • 5
    \$\begingroup\$ Can you please try to use the sandbox next time? I see that you have already gotten negative votes on two previous questions today, and now this one has been marked as a duplicate. \$\endgroup\$ – R. Kap May 2 '16 at 6:50
1
\$\begingroup\$

Actually, 23 bytes

╗'
@s`╜;)*(Zk♂ΣiΣn`M'
j

Takes the string input (with newlines represented as \ns to make multi-line input work) as the first input and the integer as the second.

Try it online!

Explanation (newlines replaced with \n):

╗'\n@s`╜;)*(Zk♂ΣiΣn`M'\nj
╗                          push n to reg0
 '\n@s                     split s on newlines
      `╜;)*(Zk♂ΣiΣn`M      for each line:
       ╜;)*(Z                make n copies and zip them
             k♂ΣiΣ           join the strings ("abc" -> ["abc", "abc"] -> "aabbcc" with n = 2)
                  n          make n copies of the result line
                     '\nj  join on newline
\$\endgroup\$
  • \$\begingroup\$ Actually, this is quite long... (Pyth may need not more than 10 bytes I reckon) \$\endgroup\$ – Leaky Nun May 2 '16 at 6:27
  • \$\begingroup\$ @KennyLau Actually doesn't do well with string manipulation. Its strength is math. \$\endgroup\$ – Mego May 2 '16 at 6:29
  • \$\begingroup\$ So, this looks like an old answer, but I don't think \n is actually part of CP437. \$\endgroup\$ – Erik the Outgolfer Jun 4 '18 at 12:39

Not the answer you're looking for? Browse other questions tagged or ask your own question.