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

77%
+5 −0
Challenges Longest parallel lines

Note: This challenge was underspecified and bad, and as such I would not encourage answering it in the future. Challenge You will be given a single 2D boolean array $M$. You may take its dimensi...

1 answer  ·  posted 3y ago by rak1507‭  ·  edited 3y ago by rak1507‭

Question code-golf boolean
#2: Post edited by user avatar rak1507‭ · 2021-05-30T20:32:20Z (almost 3 years ago)
  • # Challenge
  • You will be given a single 2D boolean array \$M\$. You may take its dimensions as a separate argument if needed.
  • Find the longest parallel lines in the matrix.
  • Parallel lines can be vertical, horizontal, or diagonal, and there can't be a 1 anywhere between the two lines. (Imagine 0s are air, and the 1s are solid, the two lines have to be able to 'see' each other)
  • For example, in the matrix
  • ```
  • 0 1 1 1 0 0
  • 0 0 0 0 0 0
  • 0 1 1 1 1 0
  • 0 0 1 1 0 0
  • 0 0 0 0 0 0
  • ```
  • the longest parallel line is length 3.
  • If there are no parallel lines, output 0.
  • # Test Cases
  • ```
  • I:
  • 0 0 0 1
  • 0 0 0 0
  • 0 0 0 0
  • 0 1 0 0
  • O: 0
  • I:
  • 0 0 1 0 1
  • 0 1 0 1 0
  • 1 0 1 0 0
  • O: 3
  • I:
  • 0 0 1 0 1
  • 0 0 1 0 1
  • 0 0 1 1 1
  • 0 0 1 0 1
  • 0 0 1 0 1
  • O: 2
  • (The 1 in the middle is obstructing the line of sight)
  • ```
  • # Note:
  • This challenge was underspecified and bad, and as such I would not encourage answering it in the future.
  • # Challenge
  • You will be given a single 2D boolean array \$M\$. You may take its dimensions as a separate argument if needed.
  • Find the longest parallel lines in the matrix.
  • Parallel lines can be vertical, horizontal, or diagonal, and there can't be a 1 anywhere between the two lines. (Imagine 0s are air, and the 1s are solid, the two lines have to be able to 'see' each other)
  • For example, in the matrix
  • ```
  • 0 1 1 1 0 0
  • 0 0 0 0 0 0
  • 0 1 1 1 1 0
  • 0 0 1 1 0 0
  • 0 0 0 0 0 0
  • ```
  • the longest parallel line is length 3.
  • If there are no parallel lines, output 0.
  • # Test Cases
  • ```
  • I:
  • 0 0 0 1
  • 0 0 0 0
  • 0 0 0 0
  • 0 1 0 0
  • O: 0
  • I:
  • 0 0 1 0 1
  • 0 1 0 1 0
  • 1 0 1 0 0
  • O: 3
  • I:
  • 0 0 1 0 1
  • 0 0 1 0 1
  • 0 0 1 1 1
  • 0 0 1 0 1
  • 0 0 1 0 1
  • O: 2
  • (The 1 in the middle is obstructing the line of sight)
  • ```
#1: Initial revision by user avatar rak1507‭ · 2021-02-02T12:43:15Z (about 3 years ago)
Longest parallel lines
# Challenge
You will be given a single 2D boolean array \$M\$. You may take its dimensions as a separate argument if needed.

Find the longest parallel lines in the matrix.
Parallel lines can be vertical, horizontal, or diagonal, and there can't be a 1 anywhere between the two lines. (Imagine 0s are air, and the 1s are solid, the two lines have to be able to 'see' each other)
For example, in the matrix
```
0 1 1 1 0 0
0 0 0 0 0 0
0 1 1 1 1 0 
0 0 1 1 0 0
0 0 0 0 0 0
```
the longest parallel line is length 3.
If there are no parallel lines, output 0.

# Test Cases
```
I:
0 0 0 1
0 0 0 0
0 0 0 0
0 1 0 0
O: 0
I:
0 0 1 0 1
0 1 0 1 0
1 0 1 0 0
O: 3
I:
0 0 1 0 1
0 0 1 0 1
0 0 1 1 1
0 0 1 0 1
0 0 1 0 1
O: 2
(The 1 in the middle is obstructing the line of sight)
```