# Shrink ASCII art

The inverse of this question.

Your challenge is to, given a piece of ASCII art generated by the above question and its enlargement factor, shrink it down to its original size.

## The enlargement process

Or look at this

ASCII art within a limited character set can be enlarged to a certain (odd) size by replacing certain characters with larger versions of themselves, like so:

-\
|
_/
, 3 =>

\
--- \
\
|
|
|
/
/
___/


Because each character is enlarged to a 3x3 square.

Only those six characters (\/|-_ ) can be enlarged, and only those will be in your input. For a more detailed explanation, see the linked challenge.

I/O may be as a char matrix, ascii art, list of rows, etc.

## Testcases



\
\
\
, 3 =>
\

---------

, 3 =>
---

|
|
|
|
|
|
|
|
| , 3 =>
|
|
|

| \       / |
|  \     /  |
|   \___/   |
|           |
|           |
|           |
\       /
\     /
\___/
, 3 =>
|\_/|
|   |
\_/

_______________
\             /
\           /
\         /
/         \
/           \
/             \
\             /
\           /
\_________/  , 3 =>
_____
\   /
/   \
\___/

/\
/  \
/    \
/      \
/        \
/          \
/            \
/              \
/  ____________  \
|  |
|  |
|  |
|  |
|  |
|  |
/      \
/        \
___/  ______  \___, 3 =>
/\
/  \
/____\
||
||
_/__\_

\        /
\      /
\    /
\  /
\/
\        /
\      /
\    /
\  /
\/    , 5 =>
\/
\/

/             /
/             /
/             /
/   -------   /
/             /
/             /
/             /
\             \
\             \
\             \
\   -------   \
\             \
\             \
\             \, 7 =>
/-/
\-\

• It would be interesting if you had to auto-detect the enlargement factor (choosing the maximum). Jan 20, 2022 at 0:22

# Jelly, 7 bytes

»/⁹ÐƤ⁺€


A monadic Link accepting a list of lines that yields a list of lines.

Try it online!

### How?

»/⁹ÐƤ⁺€ - Link: list of lists of characters, Lines; pixel size, N
ÐƤ   - for non-overlapping infixes
⁹     - ...of length: chain's right argument, N
/      - ...yield: reduce by:
-             maximum (vectorises)
(Note: space is less than any other character used)
€ - for each:
⁺  -   repeat the last link - i.e. do Ṁ⁹ÐƤ


# JavaScript (ES6), 106 bytes

x=>n=>x.replace(/.+\n.+\n.+/g,y=>[...(z=y.split
)[~-n/2]].map((w,i)=>i%3-1?"":w<"!"?z[n-1][i]:w).join)


Now actually works!

• @Fmbalbuena Rickrolling jokes are mostly fine in chat, but bringing them over to main is just clutter. Jan 19, 2022 at 21:41

# J, 20 bytes

{.@-.&' '@,;.3~2 2&\$


Try it online!

With (y x,:h w) u;.3 a we can split a into tiles of size h w while sliding the window by y x. Because we don't want overlapping tiles, we can simply build a 2x2 matrix of the input, e.g. 3 3,:3 3. On these tiles u gets applied, which flattens , the tile into a list, removes any whitespace -.&' ' and then reduces the tile to the first remaining element {..

# Charcoal, 25 bytes

ＮθＷＳ⊞υ⭆⪪ιθ⌈κＥ⪪υθ⭆⌈ι⌈Ｅι§νμ


Try it online! Link is to verbose version of code. Takes the enlargement factor followed by a list of newline-terminated strings. Explanation:

Ｎθ


Input the enlargement factor.

ＷＳ⊞υ⭆⪪ιθ⌈κ


Input the strings, but split them into substrings of length equal to the enlargement factor and take the maximum character of each substring.

Ｅ⪪υθ⭆⌈ι⌈Ｅι§νμ


Split the list of strings into sublists of length equal to the enlargement factor, then transpose the sublists and take the maximum character of each, joined back into a string, and print each sublist's string on its own line.

# JavaScript, 84 bytes

a=>n=>a.map((r,i)=>r.map((c,j)=>(d=b[i/n|0]||=[])[x=j/n|0]=d[x]?.trim()||c),b=[])&&b


f=
a=>n=>a.map((r,i)=>r.map((c,j)=>(d=b[i/n|0]||=[])[x=j/n|0]=d[x]?.trim()||c),b=[])&&b

str2mat = str => str.split('\n').map(r => [...r]);
mat2str = mat => mat.map(r => r.join('')).join('\n');
test = (s, n) => console.log(mat2str(f(str2mat(s.slice(1, -1)))(n)));

test(String.raw
\
\
\
, 3);

test(String.raw
---------
, 3);

test(String.raw
|
|
|
|
|
|
|
|
|
, 3);

test(String.raw
| \       / |
|  \     /  |
|   \___/   |
|           |
|           |
|           |
\       /
\     /
\___/
, 3);

test(String.raw
_______________
\             /
\           /
\         /
/         \
/           \
/             \
\             /
\           /
\_________/
, 3);

test(String.raw
/\
/  \
/    \
/      \
/        \
/          \
/            \
/              \
/  ____________  \
|  |
|  |
|  |
|  |
|  |
|  |
/      \
/        \
___/  ______  \___
, 3);

test(String.raw
\        /
\      /
\    /
\  /
\/
\        /
\      /
\    /
\  /
\/
, 5);

test(String.raw
/             /
/             /
/             /
/   -------   /
/             /
/             /
/             /
\             \
\             \
\             \
\   -------   \
\             \
\             \
\             \
, 7);

f n|let g[]=[];g x=maximum(take n x):g(drop n x)=g.map g