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

71%
+3 −0
Challenges Chequer checker

BQN, 32 bytesSBCS Run online! {∨´∾8(⥊(⊐⌾⥊𝕩)⍷·≠⌜˜2|/∘⥊)¨1+↕≠⥊𝕩} Brute force: tests against all boards up to the number of characters in 𝕩 using Find (⍷). Using the longest dimension is faster b...

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

Answer
#4: Post edited by user avatar Marshall Lochbaum‭ · 2022-09-25T12:52:58Z (about 2 years ago)
  • # [BQN](https://mlochbaum.github.io/BQN/), 33 bytes<sup>[SBCS](https://github.com/mlochbaum/BQN/blob/master/commentary/sbcs.bqn)</sup>
  • [Run online!](https://mlochbaum.github.io/BQN/try.html#code=Q0Mg4oaQIHviiKjCtOKIvjgo4qWKKOKKkOKMvuKlivCdlakp4o23wrfiiaDijJzLnDJ8L+KImOKliinCqDEr4oaV4omg4qWK8J2VqX0KQ0PCqCDin6gKICBbImFhIiwiYWEiXQogIFsiYXFxYWFxIiwicWFhcXFhIl0KICBbImNjY2NjY2NjIl0KCiAgWyJhYmJhYWEiXQogIFsiYyIsImMiLCJkIiwiYyJdCiAjWyJiYmFhYmJhYWJiYWFiYmFhYiJdICAjIFRha2VzIGEgZmV3IHNlY29uZHMKICBbImFiYyJdCiAgWyJhYWJiIiwiYmJjYyJdCuKfqQ==)
  • ```
  • {∨´∾8(⥊(⊐⌾⥊𝕩)⍷·≠⌜˜2|/∘⥊)¨1+↕≠⥊𝕩}
  • ```
  • Brute force: tests against all boards up to the number of characters in `𝕩` using [Find](https://mlochbaum.github.io/BQN/doc/find.html) (`⍷`). Using the longest dimension is faster but would cost a byte.
  • Not explained below, `⊐⌾⥊𝕩` applies [Classify](https://mlochbaum.github.io/BQN/doc/selfcmp.html#classify) [under](https://mlochbaum.github.io/BQN/doc/under.html) [Deshape](https://mlochbaum.github.io/BQN/doc/reshape.html) to convert the argument from characters to numbers. If there are only two unique characters, they'll be 0 and 1, and a third would be 2 and so on. The top-left character is 0, like the top left of the checkerboard, so an 8-square checkerboard will always fit if the argument is valid.
  • Also used: [Table](https://mlochbaum.github.io/BQN/doc/map.html#table), [Indices](https://mlochbaum.github.io/BQN/doc/replicate.html#indices).
  • ```
  • {∨´∾8(⥊(⊐⌾⥊𝕩)⍷·≠⌜˜2|/∘⥊)¨1+↕≠⥊𝕩}
  • ≠⥊𝕩 # Length of flattened argument
  • 1+↕ # Range from 1 to that length
  • 8( )¨ # On each size: n
  • 8 ⥊ # Take 8 of them n n n…
  • /∘ # Each index n times 0 0…0 1 1…1 2 2…2… …7
  • 2| # Mod 2 0 0…0 1 1…1 0 0…0… …1
  • ·≠⌜ # Not-equals table
  • ˜ # with itself, AKA checkerboard
  • (⊐⌾⥊𝕩)⍷ # Find the numberized argument
  • ⥊ # Convert to list
  • ∨´ # Any true in
  • ∾ # the join of that?
  • ```
  • # [BQN](https://mlochbaum.github.io/BQN/), 32 bytes<sup>[SBCS](https://github.com/mlochbaum/BQN/blob/master/commentary/sbcs.bqn)</sup>
  • [Run online!](https://mlochbaum.github.io/BQN/try.html#code=Q0Mg4oaQIHviiKjCtOKIvjgo4qWKKOKKkOKMvuKlivCdlakp4o23wrfiiaDijJzLnDJ8L+KImOKliinCqDEr4oaV4omg4qWK8J2VqX0KQ0PCqCDin6gKICBbImFhIiwiYWEiXQogIFsiYXFxYWFxIiwicWFhcXFhIl0KICBbImNjY2NjY2NjIl0KCiAgWyJhYmJhYWEiXQogIFsiYyIsImMiLCJkIiwiYyJdCiAjWyJiYmFhYmJhYWJiYWFiYmFhYiJdICAjIFRha2VzIGEgZmV3IHNlY29uZHMKICBbImFiYyJdCiAgWyJhYWJiIiwiYmJjYyJdCuKfqQ==)
  • ```
  • {∨´∾8(⥊(⊐⌾⥊𝕩)⍷·≠⌜˜2|/∘⥊)¨1+↕≠⥊𝕩}
  • ```
  • Brute force: tests against all boards up to the number of characters in `𝕩` using [Find](https://mlochbaum.github.io/BQN/doc/find.html) (`⍷`). Using the longest dimension is faster but would cost a byte.
  • Not explained below, `⊐⌾⥊𝕩` applies [Classify](https://mlochbaum.github.io/BQN/doc/selfcmp.html#classify) [under](https://mlochbaum.github.io/BQN/doc/under.html) [Deshape](https://mlochbaum.github.io/BQN/doc/reshape.html) to convert the argument from characters to numbers. If there are only two unique characters, they'll be 0 and 1, and a third would be 2 and so on. The top-left character is 0, like the top left of the checkerboard, so an 8-square checkerboard will always fit if the argument is valid.
  • Also used: [Table](https://mlochbaum.github.io/BQN/doc/map.html#table), [Indices](https://mlochbaum.github.io/BQN/doc/replicate.html#indices).
  • ```
  • {∨´∾8(⥊(⊐⌾⥊𝕩)⍷·≠⌜˜2|/∘⥊)¨1+↕≠⥊𝕩}
  • ≠⥊𝕩 # Length of flattened argument
  • 1+↕ # Range from 1 to that length
  • 8( )¨ # On each size: n
  • 8 ⥊ # Take 8 of them n n n…
  • /∘ # Each index n times 0 0…0 1 1…1 2 2…2… …7
  • 2| # Mod 2 0 0…0 1 1…1 0 0…0… …1
  • ·≠⌜ # Not-equals table
  • ˜ # with itself, AKA checkerboard
  • (⊐⌾⥊𝕩)⍷ # Find the numberized argument
  • ⥊ # Convert to list
  • ∨´ # Any true in
  • ∾ # the join of that?
  • ```
#3: Post edited by user avatar Marshall Lochbaum‭ · 2022-09-25T12:52:44Z (about 2 years ago)
  • # [BQN](https://mlochbaum.github.io/BQN/), 33 bytes<sup>[SBCS](https://github.com/mlochbaum/BQN/blob/master/commentary/sbcs.bqn)</sup>
  • [Run online!](https://mlochbaum.github.io/BQN/try.html#code=Q0Mg4oaQIHviiKjCtOKImOKIvjgo4qWKKOKKkOKMvuKlivCdlakp4o23wrfiiaDijJzLnDJ8L+KImOKliinCqDEr4oaV4omg4qWK8J2VqX0KQ0PCqCDin6gKICBbImFhIiwiYWEiXQogIFsiYXFxYWFxIiwicWFhcXFhIl0KICBbImNjY2NjY2NjIl0KCiAgWyJhYmJhYWEiXQogIFsiYyIsImMiLCJkIiwiYyJdCiAjWyJiYmFhYmJhYWJiYWFiYmFhYiJdICAjIFRha2VzIGEgZmV3IHNlY29uZHMKICBbImFiYyJdCiAgWyJhYWJiIiwiYmJjYyJdCuKfqQ==)
  • ```
  • {∨´∾8(⥊(⊐⌾⥊𝕩)⍷·≠⌜˜2|/∘⥊)¨1+↕≠⥊𝕩}
  • ```
  • Brute force: tests against all boards up to the number of characters in `𝕩` using [Find](https://mlochbaum.github.io/BQN/doc/find.html) (`⍷`). Using the longest dimension is faster but would cost a byte.
  • Not explained below, `⊐⌾⥊𝕩` applies [Classify](https://mlochbaum.github.io/BQN/doc/selfcmp.html#classify) [under](https://mlochbaum.github.io/BQN/doc/under.html) [Deshape](https://mlochbaum.github.io/BQN/doc/reshape.html) to convert the argument from characters to numbers. If there are only two unique characters, they'll be 0 and 1, and a third would be 2 and so on. The top-left character is 0, like the top left of the checkerboard, so an 8-square checkerboard will always fit if the argument is valid.
  • Also used: [Table](https://mlochbaum.github.io/BQN/doc/map.html#table), [Indices](https://mlochbaum.github.io/BQN/doc/replicate.html#indices).
  • ```
  • {∨´∾8(⥊(⊐⌾⥊𝕩)⍷·≠⌜˜2|/∘⥊)¨1+↕≠⥊𝕩}
  • ≠⥊𝕩 # Length of flattened argument
  • 1+↕ # Range from 1 to that length
  • 8( )¨ # On each size: n
  • 8 ⥊ # Take 8 of them n n n…
  • /∘ # Each index n times 0…0 1…1 2…2 … 7…7
  • 2| # Mod 2 0…0 1…1 0…0 … 1…1
  • ·≠⌜ # Not-equals table
  • ˜ # with itself, AKA checkerboard
  • (⊐⌾⥊𝕩)⍷ # Find the numberized argument
  • ⥊ # Convert to list
  • ∨´ # Any true in
  • ∾ # the join of that?
  • ```
  • # [BQN](https://mlochbaum.github.io/BQN/), 33 bytes<sup>[SBCS](https://github.com/mlochbaum/BQN/blob/master/commentary/sbcs.bqn)</sup>
  • [Run online!](https://mlochbaum.github.io/BQN/try.html#code=Q0Mg4oaQIHviiKjCtOKIvjgo4qWKKOKKkOKMvuKlivCdlakp4o23wrfiiaDijJzLnDJ8L+KImOKliinCqDEr4oaV4omg4qWK8J2VqX0KQ0PCqCDin6gKICBbImFhIiwiYWEiXQogIFsiYXFxYWFxIiwicWFhcXFhIl0KICBbImNjY2NjY2NjIl0KCiAgWyJhYmJhYWEiXQogIFsiYyIsImMiLCJkIiwiYyJdCiAjWyJiYmFhYmJhYWJiYWFiYmFhYiJdICAjIFRha2VzIGEgZmV3IHNlY29uZHMKICBbImFiYyJdCiAgWyJhYWJiIiwiYmJjYyJdCuKfqQ==)
  • ```
  • {∨´∾8(⥊(⊐⌾⥊𝕩)⍷·≠⌜˜2|/∘⥊)¨1+↕≠⥊𝕩}
  • ```
  • Brute force: tests against all boards up to the number of characters in `𝕩` using [Find](https://mlochbaum.github.io/BQN/doc/find.html) (`⍷`). Using the longest dimension is faster but would cost a byte.
  • Not explained below, `⊐⌾⥊𝕩` applies [Classify](https://mlochbaum.github.io/BQN/doc/selfcmp.html#classify) [under](https://mlochbaum.github.io/BQN/doc/under.html) [Deshape](https://mlochbaum.github.io/BQN/doc/reshape.html) to convert the argument from characters to numbers. If there are only two unique characters, they'll be 0 and 1, and a third would be 2 and so on. The top-left character is 0, like the top left of the checkerboard, so an 8-square checkerboard will always fit if the argument is valid.
  • Also used: [Table](https://mlochbaum.github.io/BQN/doc/map.html#table), [Indices](https://mlochbaum.github.io/BQN/doc/replicate.html#indices).
  • ```
  • {∨´∾8(⥊(⊐⌾⥊𝕩)⍷·≠⌜˜2|/∘⥊)¨1+↕≠⥊𝕩}
  • ≠⥊𝕩 # Length of flattened argument
  • 1+↕ # Range from 1 to that length
  • 8( )¨ # On each size: n
  • 8 ⥊ # Take 8 of them n n n…
  • /∘ # Each index n times 0 0…0 1 1…1 2 2…2… …7
  • 2| # Mod 2 0 0…0 1 1…1 0 0…0… …1
  • ·≠⌜ # Not-equals table
  • ˜ # with itself, AKA checkerboard
  • (⊐⌾⥊𝕩)⍷ # Find the numberized argument
  • ⥊ # Convert to list
  • ∨´ # Any true in
  • ∾ # the join of that?
  • ```
#2: Post edited by user avatar Marshall Lochbaum‭ · 2022-09-25T12:47:22Z (about 2 years ago)
  • # [BQN](https://mlochbaum.github.io/BQN/), 33 bytes<sup>[SBCS](https://github.com/mlochbaum/BQN/blob/master/commentary/sbcs.bqn)</sup>
  • [Run online!](https://mlochbaum.github.io/BQN/try.html#code=Q0Mg4oaQIHviiKjCtOKImOKIvjgo4qWKKOKKkOKMvuKlivCdlakp4o23wrfiiaDijJzLnDJ8L+KImOKliinCqDEr4oaV4omg4qWK8J2VqX0KQ0PCqCDin6gKICBbImFhIiwiYWEiXQogIFsiYXFxYWFxIiwicWFhcXFhIl0KICBbImNjY2NjY2NjIl0KCiAgWyJhYmJhYWEiXQogIFsiYyIsImMiLCJkIiwiYyJdCiAjWyJiYmFhYmJhYWJiYWFiYmFhYiJdICAjIFRha2VzIGEgZmV3IHNlY29uZHMKICBbImFiYyJdCiAgWyJhYWJiIiwiYmJjYyJdCuKfqQ==)
  • ```
  • {∨´∘∾8(⥊(⊐⌾⥊𝕩)⍷·≠⌜˜2|/∘⥊)¨1+↕≠⥊𝕩}
  • ```
  • Brute force: tests against all boards up to the number of characters in `𝕩` using [Find](https://mlochbaum.github.io/BQN/doc/find.html) (`⍷`). Using the longest dimension is faster but would cost a byte.
  • Not explained below, `⊐⌾⥊𝕩` applies [Classify](https://mlochbaum.github.io/BQN/doc/selfcmp.html#classify) [under](https://mlochbaum.github.io/BQN/doc/under.html) [Deshape](https://mlochbaum.github.io/BQN/doc/reshape.html) to convert the argument from characters to numbers. If there are only two unique characters, they'll be 0 and 1, and a third would be 2 and so on. The top-left character is 0, like the top left of the checkerboard, so an 8-square checkerboard will always fit if the argument is valid.
  • Also used: [Table](https://mlochbaum.github.io/BQN/doc/map.html#table), [Indices](https://mlochbaum.github.io/BQN/doc/replicate.html#indices).
  • ```
  • {∨´∘∾8(⥊(⊐⌾⥊𝕩)⍷·≠⌜˜2|/∘⥊)¨1+↕≠⥊𝕩}
  • ≠⥊𝕩 # Length of flattened argument
  • 1+↕ # Range from 1 to that length
  • 8( )¨ # On each size: n
  • 8 ⥊ # Take 8 of them n n n…
  • /∘ # Each index n times 0 0…0 1 1…1 2 2…2… …7
  • 2| # Mod 2 0 0…0 1 1…1 0 0…0… …1
  • ·≠⌜ # Not-equals table
  • ˜ # with itself, AKA checkerboard
  • (⊐⌾⥊𝕩)⍷ # Find the numberized argument
  • ⥊ # Convert to list
  • ∨´ # Any true in
  • ∘∾ # the join of that?
  • ```
  • # [BQN](https://mlochbaum.github.io/BQN/), 33 bytes<sup>[SBCS](https://github.com/mlochbaum/BQN/blob/master/commentary/sbcs.bqn)</sup>
  • [Run online!](https://mlochbaum.github.io/BQN/try.html#code=Q0Mg4oaQIHviiKjCtOKImOKIvjgo4qWKKOKKkOKMvuKlivCdlakp4o23wrfiiaDijJzLnDJ8L+KImOKliinCqDEr4oaV4omg4qWK8J2VqX0KQ0PCqCDin6gKICBbImFhIiwiYWEiXQogIFsiYXFxYWFxIiwicWFhcXFhIl0KICBbImNjY2NjY2NjIl0KCiAgWyJhYmJhYWEiXQogIFsiYyIsImMiLCJkIiwiYyJdCiAjWyJiYmFhYmJhYWJiYWFiYmFhYiJdICAjIFRha2VzIGEgZmV3IHNlY29uZHMKICBbImFiYyJdCiAgWyJhYWJiIiwiYmJjYyJdCuKfqQ==)
  • ```
  • {∨´∘∾8(⥊(⊐⌾⥊𝕩)⍷·≠⌜˜2|/∘⥊)¨1+↕≠⥊𝕩}
  • ```
  • Brute force: tests against all boards up to the number of characters in `𝕩` using [Find](https://mlochbaum.github.io/BQN/doc/find.html) (`⍷`). Using the longest dimension is faster but would cost a byte.
  • Not explained below, `⊐⌾⥊𝕩` applies [Classify](https://mlochbaum.github.io/BQN/doc/selfcmp.html#classify) [under](https://mlochbaum.github.io/BQN/doc/under.html) [Deshape](https://mlochbaum.github.io/BQN/doc/reshape.html) to convert the argument from characters to numbers. If there are only two unique characters, they'll be 0 and 1, and a third would be 2 and so on. The top-left character is 0, like the top left of the checkerboard, so an 8-square checkerboard will always fit if the argument is valid.
  • Also used: [Table](https://mlochbaum.github.io/BQN/doc/map.html#table), [Indices](https://mlochbaum.github.io/BQN/doc/replicate.html#indices).
  • ```
  • {∨´∘∾8(⥊(⊐⌾⥊𝕩)⍷·≠⌜˜2|/∘⥊)¨1+↕≠⥊𝕩}
  • ≠⥊𝕩 # Length of flattened argument
  • 1+↕ # Range from 1 to that length
  • 8( )¨ # On each size: n
  • 8 ⥊ # Take 8 of them n n n…
  • /∘ # Each index n times 0…0 1…1 2…2 … 7…7
  • 2| # Mod 2 0…0 1…1 0…0 … 1…1
  • ·≠⌜ # Not-equals table
  • ˜ # with itself, AKA checkerboard
  • (⊐⌾⥊𝕩)⍷ # Find the numberized argument
  • ⥊ # Convert to list
  • ∨´ # Any true in
  • ∘∾ # the join of that?
  • ```
#1: Initial revision by user avatar Marshall Lochbaum‭ · 2022-09-25T12:44:03Z (about 2 years ago)
# [BQN](https://mlochbaum.github.io/BQN/), 33 bytes<sup>[SBCS](https://github.com/mlochbaum/BQN/blob/master/commentary/sbcs.bqn)</sup>

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

```
{∨´∘∾8(⥊(⊐⌾⥊𝕩)⍷·≠⌜˜2|/∘⥊)¨1+↕≠⥊𝕩}
```

Brute force: tests against all boards up to the number of characters in `𝕩` using [Find](https://mlochbaum.github.io/BQN/doc/find.html) (`⍷`). Using the longest dimension is faster but would cost a byte.

Not explained below, `⊐⌾⥊𝕩` applies [Classify](https://mlochbaum.github.io/BQN/doc/selfcmp.html#classify) [under](https://mlochbaum.github.io/BQN/doc/under.html) [Deshape](https://mlochbaum.github.io/BQN/doc/reshape.html) to convert the argument from characters to numbers. If there are only two unique characters, they'll be 0 and 1, and a third would be 2 and so on. The top-left character is 0, like the top left of the checkerboard, so an 8-square checkerboard will always fit if the argument is valid.

Also used: [Table](https://mlochbaum.github.io/BQN/doc/map.html#table), [Indices](https://mlochbaum.github.io/BQN/doc/replicate.html#indices).

```
{∨´∘∾8(⥊(⊐⌾⥊𝕩)⍷·≠⌜˜2|/∘⥊)¨1+↕≠⥊𝕩}
                             ≠⥊𝕩   # Length of flattened argument
                          1+↕      # Range from 1 to that length
     8(                 )¨         # On each size:        n
     8                 ⥊           #   Take 8 of them     n n n…
                     /∘            #   Each index n times 0 0…0 1 1…1 2 2…2… …7
                   2|              #   Mod 2              0 0…0 1 1…1 0 0…0… …1
               ·≠⌜                 #   Not-equals table
                  ˜                #     with itself, AKA checkerboard
        (⊐⌾⥊𝕩)⍷                    #   Find the numberized argument
       ⥊                           #   Convert to list
 ∨´                                # Any true in
   ∘∾                              #   the join of that?
```