Å4bS{I·ƒDÂ~„ *èJ,À
在线尝试!
说明
范例 n=2
Å4 # push a list of 4s with length as the input
# STACK: [4,4]
b # convert each to binary
# STACK: [100, 100]
S{ # split into digit list and sort
# STACK: [0, 0, 0, 0, 1, 1]
I·ƒ # input*2+1 times do
D # duplicate top of stack
# 1st iteration: [0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 1, 1]
# 2nd iteration: [0, 0, 0, 1, 1, 0], [0, 0, 0, 1, 1, 0]
# 3rd iteration: [0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0]
Â~ # or each item in the duplicate with its reverse
# 1st iteration: [0, 0, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1]
# 2nd iteration: [0, 0, 0, 1, 1, 0], [0, 1, 1, 1, 1, 0]
# 3rd iteration: [0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0]
„ *èJ # use the resulting binary list to index into the string " *"
# 1st iteration: [0, 0, 0, 0, 1, 1], "** **"
# 2nd iteration: [0, 0, 0, 1, 1, 0], " **** "
# 3rd iteration: [0, 0, 1, 1, 0, 0], " ** "
, # print
À # rotate list left
1
替代*
和0
替代空间?