ハスク、7 6バイト
さまざまな方法がありますが(トリッキー/コストのかかる部分は除去されます[0,0]
)、10バイト変換()をフィルターとして使用することを指摘してくれたLeoのおかげで、7バイトが最短になりましたd
。
fdπ2ṡ1
オンラインでお試しください!
説明
fdπ2ṡ1 -- constant function (expects no arguments)
ṡ1 -- symmetric range [-n..n]: [-1,0,1]
π2 -- cartesian power of 2: [[-1,-1],[-1,0],[0,-1],[-1,1],[0,0],[1,-1],[0,1],[1,0],[1,1]]
f -- filter only elements that are truthy when
d -- | decimal conversion (interpret as polynomial and evaluate at x=10)
-- : [[-1,-1],[-1,0],[0,-1],[-1,1],[1,-1],[0,1],[1,0],[1,1]]
代替、7バイト
tπ2ṙ1ṡ1
オンラインでお試しください!
説明
tπ2ṙ1ṡ1 -- constant function (expects no arguments)
ṡ1 -- symmetric range [-n..n]: [-1,0,1]
ṙ1 -- rotate by 1: [0,1,-1]
π2 -- cartesian power of 2: [[0,0],[0,1],[1,0],[0,-1],[1,1],[-1,0],[1,-1],[-1,1],[-1,-1]]
t -- tail: [[0,1],[1,0],[0,-1],[1,1],[-1,0],[1,-1],[-1,1],[-1,-1]]