# Convert LifeOnTheEdge to LifeOnTheSlope

Your task here is to take a LifeOnTheEdge pattern and convert it to LifeOnTheSlope.

A LifeOnTheEdge pattern is composed of these four characters: |_L . A pattern corresponds to a certain arrangement of "on" edges in a square grid. The pattern is placed in the grid first with the characters in the cells, and each of the four letters specifies the state of the edges on the left and the bottom of that cell. | means the edge on the left is on, _ means the bottom edge is on, L means both of them are on and means neither of them are on.

For example the following LifeOnTheEdge:

|_L
|

translates to:

. . . . .
|   |
. ._._. .
|
. . . . .

Your task is however convert it to LifeOnTheSlope. LifeOnTheSlope is a LifeOnTheEdge equivalent but only uses three symbols: /\ . You should rotate the pattern 45-degree clockwise, for example the above example translates to:

/

/\/
\

This is , so shortest answer wins.

EDIT: You can have leading and/or trailing spaces/newlines as long as the output itself (somewhere on the screen) is correct.

## Test Cases

Input:
|_L
|
Output:
/

/\/
\

Input:
|
_L
L_|
L_|
L_|
L_|
|
|
Output:
/
/\/
/\ \
/\ \/
/\ \/
\ \/
/\/
/

Input:
__ __ __ __   __ __   __
|  | | ||L_   |_ | || L_
L_ L_|_L|L_   L_|L_|L |

Output:
/\
/  \
\
\  /\
/  \
\  /
\/  \
/\
\/ /
\/ /\
/\ \
\ \
\

/\
/  \
\ \
\/ /\
/  \
\  /
\/ /
/
\  /\
/\ \
\
$$`$$
• This question didn't get much attention in the sandbox, so if the I/O format looks cumbersome to you or there's other issue or this is a dupe, sorry. Aug 24, 2020 at 14:23
• Can we have leading and/or trailing spaces/newlines as long as the output itself (somewhere on the screen) is correct? Also, could you perhaps add a few more test cases (perhaps some bigger ones)? Aug 24, 2020 at 15:46
• See my answer for some suggested test cases (cc @KevinCruijssen). Aug 24, 2020 at 16:23
• @KevinCruijssen Yes you can. Downvoters explain. Aug 25, 2020 at 3:22

# JavaScript (ES6),  135 120  119 bytes

Saved 16 bytes thanks to @Shaggy!

Expects either an array of strings or a matrix of characters. Returns a matrix of characters.

a=>[...a,...a[0]].map((_,y,b)=>b.map((_,x)=>'\\/ '[(c=(a[~(x-=y+a.length)>>1]||0)[x+y-~y>>1])=='_|'[x&=1]|c=='L'?x:2]))

Try it online!

• 120? Aug 24, 2020 at 16:34
• @Shaggy Nice! Thank you. Aug 24, 2020 at 16:44
• 119 by ditching i. Aug 24, 2020 at 16:53

# Charcoal, 27 bytes

ＷＳ«Ｐ↘⭆ι§ /№|Lκ↓Ｐ↘⭆ι§ \№_Lκ←

Try it online! Link is to verbose version of code. Takes input as a newline-terminated list. Explanation:

ＷＳ«

For each line in the list...

Ｐ↘⭆ι§ /№|Lκ

Diagonally print /s for |s and Ls otherwise print spaces.

Move to the next line.

Ｐ↘⭆ι§ \№_Lκ

Diagonally print \s for _s and Ls otherwise print spaces.

Move to the previous column.

# C (gcc), 195 186 bytes

T,N,a,A,b,x,y,z;f(m,X,Y)char*m;{for(x=T=y=0;x<Y*3;x++,y++,T+=~Y)for(z=X-~Y,a=x,b=y;z--;T++,b--)A=a++/2-Y,N=m[A+b/2*X],putchar(z?(A|b)>=0&A<X&b<Y*2?T%2?N%19?32:92:(N-76)%48?32:47:32:10);}

Try it online!

• Saved 11 thanks to @ceilingcat

Example size X=3, Y=2

00 10 20  (x,y) indexes
01 11 21  of LOnH
mapped to below

-2 0|-2 0|-1-1|-1-1| 0-2|
-2 0|-1 0|-1 0| 0-1| 0-1|
-1 1|-1 0| 0 0| 0 0| 1-1|
-1 1| 0 1| 0 0| 1 0| 1 0|
0 2| 0 1| 1 1| 1 0| 2 0|
0 2| 1 2| 1 1| 2 1| 2 0|
1 3| 1 2| 2 2| 2 1| 3 1|
1 3| 2 3| 2 2| 3 2| 3 1|

We decrement x / increment y every 2 on first column and we do the inverse on each row.

Then we mask taking only valid indexes.

|    |    |    |    |
|    |    |    |    |
|    | 0 0|    |    |
| 0 1| 0 0| 1 0|    |
| 0 1| 1 1| 1 0| 2 0|
|    | 1 1| 2 1| 2 0|
|    |    | 2 1|    |
|    |    |    |    |

Now we have doubled (x,y) pairs one for |,L and the second for _,L