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 Connected ​bits

Indicate whether the 1s and 0s in an 8 by 8 grid are connected. The grid Connectedness is by orthogonal adjacency (up, down, left, right). Diagonal adjacency does not count. If all of the 1s ...

2 answers  ·  posted 7mo ago by trichoplax‭  ·  last activity 3mo ago by jhnc‭

Question code-golf binary
#2: Post edited by user avatar trichoplax‭ · 2026-03-31T13:34:12Z (6 months ago)
Add test cases that are connected only toroidally
  • Indicate whether the `1`s and `0`s in an 8 by 8 grid are connected.
  • ## The grid
  • - Connectedness is by orthogonal adjacency (up, down, left, right).
  • - Diagonal adjacency does not count.
  • - If all of the `1`s can be reached by orthogonal steps from any other `1`, stepping on only `1`s, then the set of `1`s is connected.
  • - If all of the `0`s can be reached by orthogonal steps from any other `0`, stepping on only `0`s, then the set of `0`s is connected.
  • - The grid does not wrap toroidally. The left hand edge is not adjacent to the right hand edge, and the top edge is not adjacent to the bottom edge.
  • ## Input
  • - An 8 by 8 grid of `1`s and `0`s. This can be in any format that does not contribute to solving the challenge. For example:
  • - 8 strings of 8 characters.
  • - A string of 64 characters.
  • - A string of newline separated strings of 8 characters.
  • - A sequence of 8 8 bit values.
  • - A 64 bit value (such as an unsigned integer).
  • ## Output
  • - An indication of whether all of the like values are connected. That is, all of the `1`s are connected and all of the `0`s are connected.
  • - This could be one of 2 distinct values to indicate true or false, or any truthy or falsy value if your language has this concept.
  • ## Examples
  • ### Connected
  • ```text
  • 00000000
  • 00000000
  • 01111000
  • 01111000
  • 01111000
  • 00000000
  • 00000000
  • 00000000
  • 00000000
  • ```
  • ### `1`s not connected
  • ```text
  • 11111111
  • 00000000
  • 00000000
  • 00000000
  • 00000000
  • 00000000
  • 00000000
  • 11111111
  • ```
  • ### `0`s not connected
  • Diagonal connection does not count.
  • ```text
  • 11111111
  • 11001111
  • 11001111
  • 11110011
  • 11110011
  • 11111111
  • 11111111
  • 11111111
  • ```
  • ### Neither connected
  • ```text
  • 00000001
  • 00000010
  • 00000100
  • 00001000
  • 00010000
  • 00100000
  • 01000000
  • 10000000
  • ```
  • ### Trivially connected
  • The empty set is considered to be connected, so if there are no `1`s, the set of `1`s is connected. Similarly for `0`s.
  • ```text
  • 00000000
  • 00000000
  • 00000000
  • 00000000
  • 00000000
  • 00000000
  • 00000000
  • 00000000
  • ```
  • ```text
  • 11111111
  • 11111111
  • 11111111
  • 11111111
  • 11111111
  • 11111111
  • 11111111
  • 11111111
  • ```
  • ## Test cases
  • Each test case is in the format `input : output`.
  • ### Unsigned integer input
  • ```text
  • 0 : true
  • 18446744073709551615 : true
  • 1 : true
  • 257 : true
  • 258 : false
  • 33909453996687360 : true
  • 18374686479671623935 : false
  • 18433180446528372735 : false
  • 72624976668147840 : false
  • 18375105691386724735 : true
  • 67178694441613952 : true
  • 18375101293340213631 : false
  • ```
  • ### Binary input
  • ```text
  • 0000000000000000000000000000000000000000000000000000000000000000 : true
  • 1111111111111111111111111111111111111111111111111111111111111111 : true
  • 0000000000000000000000000000000000000000000000000000000000000001 : true
  • 0000000000000000000000000000000000000000000000000000000100000001 : true
  • 0000000000000000000000000000000000000000000000000000000100000010 : false
  • 0000000001111000011110000111100000000000000000000000000000000000 : true
  • 1111111100000000000000000000000000000000000000000000000011111111 : false
  • 1111111111001111110011111111001111110011111111111111111111111111 : false
  • 0000000100000010000001000000100000010000001000000100000010000000 : false
  • 1111111100000001011111010100010101010101010111010100000101111111 : true
  • 0000000011101110101010101010101010101010101010101011101010000000 : true
  • 1111111100000001011110010100010101010101010111010100000101111111 : false
  • ```
  • ## Scoring
  • This is a [code golf challenge]. Your score is the number of bytes in your code. Lowest score for each language wins.
  • > Explanations are optional, but I'm more likely to upvote answers that have one.
  • [code golf challenge]: https://codegolf.codidact.com/categories/49/tags/4274 "The code-golf tag"
  • Indicate whether the `1`s and `0`s in an 8 by 8 grid are connected.
  • ## The grid
  • - Connectedness is by orthogonal adjacency (up, down, left, right).
  • - Diagonal adjacency does not count.
  • - If all of the `1`s can be reached by orthogonal steps from any other `1`, stepping on only `1`s, then the set of `1`s is connected.
  • - If all of the `0`s can be reached by orthogonal steps from any other `0`, stepping on only `0`s, then the set of `0`s is connected.
  • - The grid does not wrap toroidally. The left hand edge is not adjacent to the right hand edge, and the top edge is not adjacent to the bottom edge.
  • ## Input
  • - An 8 by 8 grid of `1`s and `0`s. This can be in any format that does not contribute to solving the challenge. For example:
  • - 8 strings of 8 characters.
  • - A string of 64 characters.
  • - A string of newline separated strings of 8 characters.
  • - A sequence of 8 8 bit values.
  • - A 64 bit value (such as an unsigned integer).
  • ## Output
  • - An indication of whether all of the like values are connected. That is, all of the `1`s are connected and all of the `0`s are connected.
  • - This could be one of 2 distinct values to indicate true or false, or any truthy or falsy value if your language has this concept.
  • ## Examples
  • ### Connected
  • ```text
  • 00000000
  • 00000000
  • 01111000
  • 01111000
  • 01111000
  • 00000000
  • 00000000
  • 00000000
  • 00000000
  • ```
  • ### `1`s not connected
  • ```text
  • 11111111
  • 00000000
  • 00000000
  • 00000000
  • 00000000
  • 00000000
  • 00000000
  • 11111111
  • ```
  • ### `0`s not connected
  • Diagonal connection does not count.
  • ```text
  • 11111111
  • 11001111
  • 11001111
  • 11110011
  • 11110011
  • 11111111
  • 11111111
  • 11111111
  • ```
  • ### Neither connected
  • ```text
  • 00000001
  • 00000010
  • 00000100
  • 00001000
  • 00010000
  • 00100000
  • 01000000
  • 10000000
  • ```
  • ### Trivially connected
  • The empty set is considered to be connected, so if there are no `1`s, the set of `1`s is connected. Similarly for `0`s.
  • ```text
  • 00000000
  • 00000000
  • 00000000
  • 00000000
  • 00000000
  • 00000000
  • 00000000
  • 00000000
  • ```
  • ```text
  • 11111111
  • 11111111
  • 11111111
  • 11111111
  • 11111111
  • 11111111
  • 11111111
  • 11111111
  • ```
  • ## Test cases
  • Each test case is in the format `input : output`.
  • ### Unsigned integer input
  • ```text
  • 0 : true
  • 18446744073709551615 : true
  • 1 : true
  • 257 : true
  • 258 : false
  • 33909453996687360 : true
  • 18374686479671623935 : false
  • 18433180446528372735 : false
  • 72624976668147840 : false
  • 18375105691386724735 : true
  • 67178694441613952 : true
  • 18375101293340213631 : false
  • 4050987864819775544 : false
  • 215245557596160 : false
  • ```
  • ### Binary input
  • ```text
  • 0000000000000000000000000000000000000000000000000000000000000000 : true
  • 1111111111111111111111111111111111111111111111111111111111111111 : true
  • 0000000000000000000000000000000000000000000000000000000000000001 : true
  • 0000000000000000000000000000000000000000000000000000000100000001 : true
  • 0000000000000000000000000000000000000000000000000000000100000010 : false
  • 0000000001111000011110000111100000000000000000000000000000000000 : true
  • 1111111100000000000000000000000000000000000000000000000011111111 : false
  • 1111111111001111110011111111001111110011111111111111111111111111 : false
  • 0000000100000010000001000000100000010000001000000100000010000000 : false
  • 1111111100000001011111010100010101010101010111010100000101111111 : true
  • 0000000011101110101010101010101010101010101010101011101010000000 : true
  • 1111111100000001011110010100010101010101010111010100000101111111 : false
  • 0011100000111000000000000000000000000000000000000011100000111000 : false
  • 0000000000000000110000111100001111000011000000000000000000000000 : false
  • ```
  • ## Scoring
  • This is a [code golf challenge]. Your score is the number of bytes in your code. Lowest score for each language wins.
  • > Explanations are optional, but I'm more likely to upvote answers that have one.
  • [code golf challenge]: https://codegolf.codidact.com/categories/49/tags/4274 "The code-golf tag"
#1: Initial revision by user avatar trichoplax‭ · 2026-03-05T14:26:30Z (7 months ago)
Connected ​bits
Indicate whether the `1`s and `0`s in an 8 by 8 grid are connected.

## The grid
- Connectedness is by orthogonal adjacency (up, down, left, right).
- Diagonal adjacency does not count.
- If all of the `1`s can be reached by orthogonal steps from any other `1`, stepping on only `1`s, then the set of `1`s is connected.
- If all of the `0`s can be reached by orthogonal steps from any other `0`, stepping on only `0`s, then the set of `0`s is connected.
- The grid does not wrap toroidally. The left hand edge is not adjacent to the right hand edge, and the top edge is not adjacent to the bottom edge.

## Input
- An 8 by 8 grid of `1`s and `0`s. This can be in any format that does not contribute to solving the challenge. For example:
  - 8 strings of 8 characters.
  - A string of 64 characters.
  - A string of newline separated strings of 8 characters.
  - A sequence of 8 8 bit values.
  - A 64 bit value (such as an unsigned integer).

## Output
- An indication of whether all of the like values are connected. That is, all of the `1`s are connected and all of the `0`s are connected.
- This could be one of 2 distinct values to indicate true or false, or any truthy or falsy value if your language has this concept.

## Examples

### Connected

```text
00000000
00000000
01111000
01111000
01111000
00000000
00000000
00000000
00000000
```

### `1`s not connected

```text
11111111
00000000
00000000
00000000
00000000
00000000
00000000
11111111
```

### `0`s not connected
Diagonal connection does not count.

```text
11111111
11001111
11001111
11110011
11110011
11111111
11111111
11111111
```

### Neither connected
```text
00000001
00000010
00000100
00001000
00010000
00100000
01000000
10000000
```

### Trivially connected
The empty set is considered to be connected, so if there are no `1`s, the set of `1`s is connected. Similarly for `0`s.

```text
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
```

```text
11111111
11111111
11111111
11111111
11111111
11111111
11111111
11111111
```

## Test cases
Each test case is in the format `input : output`.

### Unsigned integer input

```text
0 : true
18446744073709551615 : true
1 : true
257 : true
258 : false
33909453996687360 : true
18374686479671623935 : false
18433180446528372735 : false
72624976668147840 : false
18375105691386724735 : true
67178694441613952 : true
18375101293340213631 : false
```

### Binary input

```text
0000000000000000000000000000000000000000000000000000000000000000 : true
1111111111111111111111111111111111111111111111111111111111111111 : true
0000000000000000000000000000000000000000000000000000000000000001 : true
0000000000000000000000000000000000000000000000000000000100000001 : true
0000000000000000000000000000000000000000000000000000000100000010 : false
0000000001111000011110000111100000000000000000000000000000000000 : true
1111111100000000000000000000000000000000000000000000000011111111 : false
1111111111001111110011111111001111110011111111111111111111111111 : false
0000000100000010000001000000100000010000001000000100000010000000 : false
1111111100000001011111010100010101010101010111010100000101111111 : true
0000000011101110101010101010101010101010101010101011101010000000 : true
1111111100000001011110010100010101010101010111010100000101111111 : false
```

## Scoring
This is a [code golf challenge]. Your score is the number of bytes in your code. Lowest score for each language wins.

> Explanations are optional, but I'm more likely to upvote answers that have one.


[code golf challenge]: https://codegolf.codidact.com/categories/49/tags/4274 "The code-golf tag"