Rȯ1ĖŒṙ‘Ė’ḣµ;NµN0¦€U;
Ç+;ẋ2W$+⁸<3¤µFṀR,þ$e€€ị⁾# Y
온라인으로 사용해보십시오!
( 각 열 사이에 공백을 추가 하여 final Y
을 로 바꾸어 더 정사각형으로 만드십시오 G
).
어떻게?
#
중심을 기준으로 팔 의 좌표 목록 을 작성합니다. 왼쪽 위 모서리에서 네 팔의 좌표로 변환하고 중심 좌표를 추가합니다. 공간의 좌표 모든 테이블을 구축하고에 팔 설정 #
과에 공간을
줄 바꿈으로 행을 결합한다.
Rȯ1ĖŒṙ‘Ė’ḣµ;NµN0¦€U; - Link 1, arm coordinates relative to centre: arm-length a
R - range: [1,2,...,a]
ȯ1 - or 1 (stops Œṙ erroring with arm-length 0; builds no redundant coordinates in the end)
Ė - enumerate: [[1,1],[2,2],...[a,a]] (or [[1,1]] if a=0)
Œṙ - run-length decode: [1,2,2,...,a,a,...,a] (or [1] if a=0)
‘ - increment: [2,3,3,...,a+1,a+1,...,a+1] (or [2] if a=0)
Ė - enumerate: [[1,2],[2,3],...,[T(a)-a,a+1],[T(a)-a+1,a+1],...,[T(a),a+1]] where T(a)=(a+1)*a/2 (or [[1,2]] if a=0)
’ - decrement: [[0,1],[1,2],...,[T(a)-a-1,a],[T(a)-a,a],...a[T(a)-1),a]] (or [[0,1]] if a=0)
ḣ - head to a (first a of those) - these are an arm's relative coordinates from the central `#` at [0,0])
µ - monadic chain separation (call that list r)
; - r concatenated with
N - negate r (gets the opposite arm)
µ - monadic chain separation (call that list s)
€ - for €ach coordinate pair in s:
0¦ - apply to index 0 (the right of the two values):
N - negate
U - upend (reverse each pair of that, gives the other two arms)
; - concatenate that list with s (gives all four arms)
Ç+;ẋ2W$+⁸<3¤µFṀR,þ$e€€ị⁾# Y - Main link: arm-length a
Ç - call the last link(1) as a monad (get centre-relative coordinates)
+ - add a (make the coordinates relative to the top-left)
$ - last two links as a monad:
ẋ2 - repeat a twice: [a,a]
W - wrap in a list: [[a,a]] (the centre coordinate)
; - concatenate (add the centre coordinate)
¤ - nilad followed by link(s) as a nilad:
⁸ - link's left argument, a
<3 - less than three?
+ - add (a in 0,1,2 are special cases requiring a grid one-by-one more than all the rest)
µ - monadic separation (call that c)
F - flatten c into one list
Ṁ - get the maximum (the side-length of the space)
$ - last two links as a monad:
R - range: [1,2,...,side-length]
,þ - pair table: [[[1,1],[1,2],...,[1,side-length]],[[2,1],[2,2],...,[2,side-length]],...,[[side-length,1],[side-length,2],[side-length, side-length]]]
e€€ - exists in c? for €ach for €ach (1 if a # coordinate, 0 otherwise)
⁾# - literal ['#',' ']
ị - index into
Y - join with new line characters
- implicit print