3 kyu
Line Safari - Is that a line?
392 of 887dinglemouse
Description:
Kata Task
You are given a grid
, which always includes exactly two end-points indicated by X
You simply need to return true/false if you can detect a one and only one "valid" line joining those points.
A line can have the following characters :
-
= left / right|
= up / down+
= corner
Rules for valid lines
- The most basic kind of valid line is when the end-points are already adjacent
X X
XX
- The corner character (
+
) must be used for all corners (but only for corners). - If you find yourself at a corner then you must turn.
- It must be possible to follow the line with no ambiguity (lookahead of just one step, and never treading on the same spot twice).
- The line may take any path between the two points.
- Sometimes a line may be valid in one direction but not the other. Such a line is still considered valid.
- Every line "character" found in the grid must be part of the line. If extras are found then the line is not valid.
Examples
Good lines
X---------X |
X | | X |
+--------+ X--+ +--+ | X |
+-------------+ | | X--+ X------+ |
+-------+
| +++---+
X--+ +-+ X
|
Bad lines
X-----|----X
|
X
|
+
X
|
|--------+ X--- ---+ | X |
+------ | X--+ X |
+------+
| |
X-----+------+
|
X
|
Hint
Imagine yourself walking a path where you can only see your very next step. Can you know which step you must take, or not?
Algorithms
Similar Kata:
Stats:
Created | Sep 23, 2017 |
Published | Oct 4, 2017 |
Warriors Trained | 8777 |
Total Skips | 3292 |
Total Code Submissions | 21785 |
Total Times Completed | 887 |
Java Completions | 154 |
JavaScript Completions | 224 |
Python Completions | 392 |
C# Completions | 93 |
Haskell Completions | 28 |
Ruby Completions | 22 |
Total Stars | 434 |
% of votes with a positive feedback rating | 86% of 241 |
Total "Very Satisfied" Votes | 186 |
Total "Somewhat Satisfied" Votes | 44 |
Total "Not Satisfied" Votes | 11 |
Total Rank Assessments | 3 |
Average Assessed Rank | 4 kyu |
Highest Assessed Rank | 3 kyu |
Lowest Assessed Rank | 5 kyu |