Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

66%
+2 −0
Challenges Create a Sudoku

BQN, 11 9 bytesSBCS Run online! 1⌽⍟⊢⍋3|↕9 The result is a length 9 list of lists using the numbers 0 to 8. The solution is based on the 3x3 transpose list 036147258, obtained with Grade Up. T...

posted 3y ago by Marshall Lochbaum‭  ·  edited 3y ago by Marshall Lochbaum‭

Answer
#3: Post edited by user avatar Marshall Lochbaum‭ · 2021-06-28T23:28:30Z (over 3 years ago)
  • # [BQN](https://mlochbaum.github.io/BQN/), 11 bytes<sup>[SBCS](https://github.com/mlochbaum/BQN/blob/master/commentary/sbcs.bqn)</sup>
  • ```
  • 9|+⌜⟜⊐⍋3|↕9
  • ```
  • [Run online!](https://mlochbaum.github.io/BQN/try.html#code=OXwr4oyc4p+c4oqQ4o2LM3zihpU5)
  • Uses the numbers 0 to 8. The result is a 9x9 matrix.
  • Idea is to use the numbers 0 to 8 in order for rows and the 3x3 transpose 036147258 for columns. Adding these in a [table](https://mlochbaum.github.io/BQN/doc/map.html#table) modulo 9 gives a valid solution. [Grade Up](https://mlochbaum.github.io/BQN/doc/order.html#grade) is used to get the transposed sequence and [Classify](https://mlochbaum.github.io/BQN/doc/selfcmp.html#classify) gets the original ordered range back, since all values in the argument are unique.
  • ```
  • 9|+⌜⟜⊐⍋3|↕9
  • ↕9 # Range 0…8
  • 3| # Mod 3: 012012012
  • ⍋ # Grade: 036147258
  • +⌜⟜ # Addition table with…
  • ⊐ # Classify 012345678
  • 9| # Modulo 9
  • ```
  • # [BQN](https://mlochbaum.github.io/BQN/), ~~11~~ 9 bytes<sup>[SBCS](https://github.com/mlochbaum/BQN/blob/master/commentary/sbcs.bqn)</sup>
  • [Run online!](https://mlochbaum.github.io/BQN/try.html#code=MeKMveKNn+KKouKNizN84oaVOQ==)
  • ```
  • 1⌽⍟⊢⍋3|↕9
  • ```
  • The result is a length 9 list of lists using the numbers 0 to 8.
  • The solution is based on the 3x3 transpose list 036147258, obtained with [Grade Up](https://mlochbaum.github.io/BQN/doc/order.html#grade). This list is used to [repeat](https://mlochbaum.github.io/BQN/doc/repeat.html) the operation [rotating](https://mlochbaum.github.io/BQN/doc/reverse.html#rotate) itself by one. Since it's a self-inverse, each subsequent rotation starts it at a number one higher than the previous.
  • ```
  • 1⌽⍟⊢⍋3|↕9
  • ↕9 # Range 0…8
  • 3| # Mod 3: 012012012
  • ⍋ # Grade: 036147258
  • 1⌽ # Rotate by 1
  • ⍟⊢ # Repeated n times for each number n
  • ```
  • ---
  • Previous solution (11): [Run online!](https://mlochbaum.github.io/BQN/try.html#code=OXwr4oyc4p+c4oqQ4o2LM3zihpU5)
  • Idea is to use the numbers 0 to 8 in order for rows and the 3x3 transpose 036147258 for columns. Adding these in a [table](https://mlochbaum.github.io/BQN/doc/map.html#table) modulo 9 gives a valid solution. [Classify](https://mlochbaum.github.io/BQN/doc/selfcmp.html#classify) gets the original ordered range back from the transpose, since all its elements are unique.
  • ```
  • 9|+⌜⟜⊐⍋3|↕9
  • ↕9 # Range 0…8
  • 3| # Mod 3: 012012012
  • ⍋ # Grade: 036147258
  • +⌜⟜ # Addition table with…
  • ⊐ # Classify 012345678
  • 9| # Modulo 9
  • ```
#2: Post edited by user avatar Moshi‭ · 2021-06-28T23:04:00Z (over 3 years ago)
Index != value (also, challenge has been updated to explicitly allow 0-8)
  • # [BQN](https://mlochbaum.github.io/BQN/), 11 bytes<sup>[SBCS](https://github.com/mlochbaum/BQN/blob/master/commentary/sbcs.bqn)</sup>
  • ```
  • 9|+⌜⟜⊐⍋3|↕9
  • ```
  • [Run online!](https://mlochbaum.github.io/BQN/try.html#code=OXwr4oyc4p+c4oqQ4o2LM3zihpU5)
  • Assumes 0-index; add 1 for 13 bytes if 1-indexed is required. The result is a 9x9 matrix.
  • Idea is to use the numbers 0 to 8 in order for rows and the 3x3 transpose 036147258 for columns. Adding these in a [table](https://mlochbaum.github.io/BQN/doc/map.html#table) modulo 9 gives a valid solution. [Grade Up](https://mlochbaum.github.io/BQN/doc/order.html#grade) is used to get the transposed sequence and [Classify](https://mlochbaum.github.io/BQN/doc/selfcmp.html#classify) gets the original ordered range back, since all values in the argument are unique.
  • ```
  • 9|+⌜⟜⊐⍋3|↕9
  • ↕9 # Range 0…8
  • 3| # Mod 3: 012012012
  • ⍋ # Grade: 036147258
  • +⌜⟜ # Addition table with…
  • ⊐ # Classify 012345678
  • 9| # Modulo 9
  • ```
  • # [BQN](https://mlochbaum.github.io/BQN/), 11 bytes<sup>[SBCS](https://github.com/mlochbaum/BQN/blob/master/commentary/sbcs.bqn)</sup>
  • ```
  • 9|+⌜⟜⊐⍋3|↕9
  • ```
  • [Run online!](https://mlochbaum.github.io/BQN/try.html#code=OXwr4oyc4p+c4oqQ4o2LM3zihpU5)
  • Uses the numbers 0 to 8. The result is a 9x9 matrix.
  • Idea is to use the numbers 0 to 8 in order for rows and the 3x3 transpose 036147258 for columns. Adding these in a [table](https://mlochbaum.github.io/BQN/doc/map.html#table) modulo 9 gives a valid solution. [Grade Up](https://mlochbaum.github.io/BQN/doc/order.html#grade) is used to get the transposed sequence and [Classify](https://mlochbaum.github.io/BQN/doc/selfcmp.html#classify) gets the original ordered range back, since all values in the argument are unique.
  • ```
  • 9|+⌜⟜⊐⍋3|↕9
  • ↕9 # Range 0…8
  • 3| # Mod 3: 012012012
  • ⍋ # Grade: 036147258
  • +⌜⟜ # Addition table with…
  • ⊐ # Classify 012345678
  • 9| # Modulo 9
  • ```
#1: Initial revision by user avatar Marshall Lochbaum‭ · 2021-06-28T22:01:45Z (over 3 years ago)
# [BQN](https://mlochbaum.github.io/BQN/), 11 bytes<sup>[SBCS](https://github.com/mlochbaum/BQN/blob/master/commentary/sbcs.bqn)</sup>

```
9|+⌜⟜⊐⍋3|↕9
```

[Run online!](https://mlochbaum.github.io/BQN/try.html#code=OXwr4oyc4p+c4oqQ4o2LM3zihpU5)

Assumes 0-index; add 1 for 13 bytes if 1-indexed is required. The result is a 9x9 matrix.

Idea is to use the numbers 0 to 8 in order for rows and the 3x3 transpose 036147258 for columns. Adding these in a [table](https://mlochbaum.github.io/BQN/doc/map.html#table) modulo 9 gives a valid solution. [Grade Up](https://mlochbaum.github.io/BQN/doc/order.html#grade) is used to get the transposed sequence and [Classify](https://mlochbaum.github.io/BQN/doc/selfcmp.html#classify) gets the original ordered range back, since all values in the argument are unique.

```
9|+⌜⟜⊐⍋3|↕9
         ↕9  # Range 0…8
       3|    # Mod 3: 012012012
      ⍋      # Grade: 036147258
  +⌜⟜        # Addition table with…
     ⊐       #   Classify 012345678
9|           # Modulo 9
```