Post History
APL (Dyalog Unicode), 22 bytes ⎕←∘.((1+⍳9)⌽⍨⊣+3×⊢)⍨⍳3 Try it online! Requires zero-indexing. ⎕←∘.((1+⍳9)⌽⍨⊣+3×⊢)⍨⍳3 ⍳3 ⍝ Make the range [0, 2] (row and cols of 3×3 box...
Answer
#2: Post edited
# [APL (Dyalog Unicode)], 43 bytes- <!-- language-all: lang-apl -->
- ⎕←∘.((1+⍳9)⌽⍨⊣+3×⊢)⍨⍳3
- [Try it online!][TIO-kqh3uksj]
- [APL (Dyalog Unicode)]: https://www.dyalog.com/
- [TIO-kqh3uksj]: https://tio.run/##SyzI0U2pTMzJT///qG@qp/@jtgkGIBaQftQxQ09Dw1D7Ue9mS81HPXsf9a541LVY2/jw9EddizRBvN7Nxv//AwA "APL (Dyalog Unicode) – Try It Online"
- Requires zero-indexing.
- ```
- ⎕←∘.((1+⍳9)⌽⍨⊣+3×⊢)⍨⍳3
- ⍳3 ⍝ Make the range [0, 2] (row and cols of 3×3 boxes)
- ∘. ⍨ ⍝ Outer product with itself
- ⊣+ ⍝ Add the row to
- 3×⊢ ⍝ 3 times the column
- ⌽ ⍝ And rotate
- (1+⍳9) ⍝ The range [1,9] by that much
- ⎕← ⍝ Print that
- ```
- # [APL (Dyalog Unicode)], 22 bytes
- <!-- language-all: lang-apl -->
- ⎕←∘.((1+⍳9)⌽⍨⊣+3×⊢)⍨⍳3
- [Try it online!][TIO-kqh3uksj]
- [APL (Dyalog Unicode)]: https://www.dyalog.com/
- [TIO-kqh3uksj]: https://tio.run/##SyzI0U2pTMzJT///qG@qp/@jtgkGIBaQftQxQ09Dw1D7Ue9mS81HPXsf9a541LVY2/jw9EddizRBvN7Nxv//AwA "APL (Dyalog Unicode) – Try It Online"
- Requires zero-indexing.
- ```
- ⎕←∘.((1+⍳9)⌽⍨⊣+3×⊢)⍨⍳3
- ⍳3 ⍝ Make the range [0, 2] (row and cols of 3×3 boxes)
- ∘. ⍨ ⍝ Outer product with itself
- ⊣+ ⍝ Add the row to
- 3×⊢ ⍝ 3 times the column
- ⌽ ⍝ And rotate
- (1+⍳9) ⍝ The range [1,9] by that much
- ⎕← ⍝ Print that
- ```
#1: Initial revision
# [APL (Dyalog Unicode)], 43 bytes <!-- language-all: lang-apl --> ⎕←∘.((1+⍳9)⌽⍨⊣+3×⊢)⍨⍳3 [Try it online!][TIO-kqh3uksj] [APL (Dyalog Unicode)]: https://www.dyalog.com/ [TIO-kqh3uksj]: https://tio.run/##SyzI0U2pTMzJT///qG@qp/@jtgkGIBaQftQxQ09Dw1D7Ue9mS81HPXsf9a541LVY2/jw9EddizRBvN7Nxv//AwA "APL (Dyalog Unicode) – Try It Online" Requires zero-indexing. ``` ⎕←∘.((1+⍳9)⌽⍨⊣+3×⊢)⍨⍳3 ⍳3 ⍝ Make the range [0, 2] (row and cols of 3×3 boxes) ∘. ⍨ ⍝ Outer product with itself ⊣+ ⍝ Add the row to 3×⊢ ⍝ 3 times the column ⌽ ⍝ And rotate (1+⍳9) ⍝ The range [1,9] by that much ⎕← ⍝ Print that ```