3 kyu
Line Safari - Is that a line?
393 of 889dinglemouse
Loading description...
Algorithms
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
I suspect part of what's confusing people in this kata description is "Sometimes a line may be valid in one direction but not the other. Such a line is still considered valid."
I think, but am not sure, that you mean "Sometimes a line may be valid when starting from one endpoint, but not the other. Such a line is still considered valid". I think you do not mean something like "Sometimes a line may be valid if you take one turning at a
+
, but not a different turning at a+
. Such a line is still considered valid". (Viewed narrowly, I think that'd be a reasonable interpretation, but it's hard to make sense of given the other rules.)Right?
A line has start and end. Let's call them A and B. And sometimes the line is "valid" (by my Kata rules) in one direction only. e.g from A-to-B, or from B-to-A, but not both at the same time.
But being valid in one direction only is sufficient to call the whole line "valid".
So
Sometimes a line may be valid in one direction but not the other. Such a line is still considered valid.
means:What is the main difference between Good5 and Bad5? For me, the paths are equal.
Python test framework update: https://www.codewars.com/kumite/65d4d7527edb9b00654c85e8?sel=65d4d7527edb9b00654c85e8
Approved by someone
Traceback (most recent call last): File "/workspace/default/tests.py", line 16, in test.assert_equals(line(show(grid)), expected) ^^^^ NameError: name 'line' is not defined. Did you mean: 'slice'?
when i run my code in my pc it is working great but if i try to past the same code to codewar and run it it gives error
Did you rename the function to some other name that's not
line
?Yeah, that was hardest so far and took me a couple of hours to solve. When first tests passes you think it will be easy, but then submit tests kick in, and you think about skipping the kata. Then after hours of attempts and rereading the rules you finally understand what is considered ambiguity and what kata wants from you. It's not very clear from the rules imo.
In C# tests, test named "ExBad5" has a useless trailing comma in the last grid row. Sorry, but I had to point it out :)
Don't be sorry. Fixed!
Awesome kata. Thought this would be easier than "Blaine is a pain" because they seem similar, but it was tricky in a different way. At first I was convinced the "ambiguity" rules made no sense...then I saw it! Makes perfect sense.
Awesome kata, had to keep reading the rules cause one of the cases was tripping me up. If I had to give any advice for people failing cases it would be to reread the valid line rules.
Nice brain twister! It took me a day to get it right. The testing part is clearly solid and exaustive. Thx for this kata!
Nice kata. it was enjoyable at first but only after I passed the tests I found out that I didn't understand the description. I think that the description didn't do a good job at defining "ambiguity". It also should have specified that you can start from both points but the path doesn't have to be legal from both of the points. I think the some of the tests of "loopAmbiguous()" would make perfect examples.
Other than that, I did enjoy the kata and while I think that some of the rules are unintuitive, the tests were really good at helping me understand them. I'm amazed by the number of tests and it looks like a lot of work has gone into this kata.
and also the solution for this pattern is False, i always failed for this 2 pattern(include the previous post), can anyone help me explain why it is False? thx (python)
IIUC this is the fixed edge case test #7.
261 people already solved this in Python. That fact that your solution did not work does not mean this is an
ISSUE
.It is false because on reaching the 2nd '+' (coming from either end) you cannot know whether to turn left or right.
if you start from either
X
you find yourself at a+
with 2 ways to go, the only way to know which is correct is if you can look ahead move that 1 cell, So the answer is False.This comment has been hidden.
Oh, I see "Sometimes a line may be valid in one direction but not the other. Such a line is still considered valid."
for
I'm confused. Is there still some open question from your top post or have you worked it out now?
This pattern must True right? the solution said that it is False, can anyone explain why it is False? thx
im using python btw
Wrong.
Upon reaching the 2nd '+' (from either direction) you cannot know whether to go left or right.
.
Task description states "Sometimes a line may be valid in one direction but not the other. Such a line is still considered valid." Need either to update description or to update tests.
why?
How comes the breacumb test return false? The path is ambigious from one way, but from another it is definently onle one possible
What path? What test? There are multiple tests named like 'breadcrumb'
Breadcumbs extras X--+ | X--+ | ---+
damn, can't make it multiline, but you know how the test looks
These are false because of the rule saying "extra" characters outside of the line are not allowed.
Can someone explain me the difference between the 5th bad exemple and the 5th good exemple ? For me there are the same.
Because of this rule:
Ho i got it, it's because you can
never treading on the same spot twice
I would agree with most of the people about the deffinition of "ambiguous", it would be nice to elaborate it better in the task.
I have some interesting question, hopefuly. I suppose that this is FALSE (. is space, I don't know how to type space):
"X--+...",
"...|...",
".+-++-+",
".+--+.X"
However, if we assume "smart walker" when reaching the "critical" + it should be clear that one should turn to the -, not +. The reason is if the walker turns to +, instead of - it will certanly be impossible to complete the line, because that - must be covered sometime, but it can be reached only from the oposite side of the "critical" +, and then only option is to go again to the "critical" +, which is forbidden. Thus, it is clear that in such case the walker should turn to the -. This is wrong if we assume "dumb walke" that cannot "think" in such a way.
???
An alternative (and more successful) strategy would be to not make any assumptions, but instead just follow the rules in the Kata description.
In ex-good-#5 in javascript, last row of the matrix have an unnecessary space.
It's just a small mistake, but makes me feel uncomfortable...
I can't remember if that space was deliberate or not, but since it appears inconsistently in some translations but not others, and since I did not write anything about jagged grids in the description, most likely it was a mistake.
Anyway, now it is removed. Thanks for reporting it.
I read the discussions, and I still don't get why it's invalid test:
there is only one path forward and backward, isn't it?
is it possible to pass on corner twice but to different directions?
X
you will get to a junction. Do you turn left or right? You don't know...X
Since the line is not "valid" in either direction then it is not considered a valid line.
Sorry, I didn't understood what it mean ambiguity in terms of paths, maybe its lingo diffs...
you will get to a junction. Do you turn left or right? You don't know... What does it mean?
If I can go left (didn't stepped on this cell before) I'll try to go left, same for right...
can you please clarify this condition?: "It must be possible to follow the line with no ambiguity"
Seems like I'm not the only1 struggling with this condition..
Did you read the hint in the Kata description?
If you are not 100% sure which step you must take then line is not valid.
I agree with amitznati. In the following case (Good5):
You are also not 100% sure which path to take, however return true.
@fstnando77
From Kata description:
Why is this false? +------+ | | X-----+------+ |
X
The only valid path is down at the first +.
If I go up, then right then down then left, I need to go thorugh the same + again, which is invalid (same if I go drom second X)
Hmmm - you'll need to use markdown to reformat that line of your question, otherwise people can't see what you are talking about.
this took so long but i loved all the practice it made me go through! thanks for the brain teaser!
Alright, I think I have solved all your katas except 6Kyus+ I need some kind of DingleBadge don't you think?
Congrats! LOL - https://www.youtube.com/watch?v=VqomZQMZQCQ
I love your katas! T_T
Nice Kata!!
Would be nice if the C# tests used a char[][] as an argument so I didn't have to reimplement Preloaded.MakeGrid. Other than that awesome kata!
The fifth good example is ambiguous from both ends!
From the left: You reach the + and can go either ← or → . Ambiguous, disqualified. From the right: You reach the + and can go either ↓ or ← . Ambiguous, disqualified.
Help me out?
Wrong.
The
+
is a corner. You cannot go straight ahead through a corner.Hi dinglemouse :D
I'm sorry, but I completely don't understand — in a post earlier you said the following:
The part that says + is "only for corners" is not meant to imply the straight ahead path is disallowed. It is only saying that at least one of the outgoing paths from the + must be a turn. e.g. This is the reason for the 2nd bad-line example. If you think this Kata description is confusing please suggest something better for consideration.
Is the straight ahead path actually not allowed? :S
It has been a long time since I wrote this but IIRC when you find yourself on a
+
corner, then you MUST turn. I have updated the Kata description to say the same. Let's see if somebody can find an example to dispute that.(my reply 1yr ago was misguided I think.)
Hey :D.
Thanks for that. Likewise, I'll try and solve this kata so I can confirm!
The input
grid
given for the (Python) test "Loops > Ambiguous loop2":Does not satisfy the guarantee given in the test description:
Moreover, it contains the unspecified character
W
(a simple typo forX
?).Erk. How did that get there? Fixed!
My solution failed a single test (the "more edge cases"), can I see the corresponding mazes? I cannot find my mistake.
Just print (language specific) the parameter passed and look at the Kata output tab to see it.
Thank you, it worked. Apparentely I also misunderstood your notion of 'ambiguity'.
I wonder if it is the same i am failing, i do not understand why it is not valid.
``` +-+
| |
++++
++++
X+++
+---X
This comment has been hidden.
I think there is no problem with the description except too many people do not read it carefully.
How is it not clear? How should it be improved?
I just thought this sentence could be reformulated a bit: "It must be possible to follow the line with no ambiguity (lookahead of just one step, and never treading on the same spot twice)."
We misinterpreted it like, if you have two options to go from a corner, but only one leads to a valid path, then the line would still be valid.
I'm no native speaker, but what about something like: "It must be possible to follow the line without ever treading on the same spot twice, and by going step by step without ever having to choose between two adjacent and still unvisited tiles to go next. (The latter condition might hold only in one direction. The line will still be considered valid in this case.)"
The best kata I've done so far. It took me a couple of days of thinking how to implement it. Thank you!
Two of the paths I don't understand why they should fail:
This one is apparently false for ambiguousness... but I am not clear from the instructions why:
The second one is this and all the test says is that it is an edge case but it looks like it has only one legit path (well from each direction). Why is this one false?
First answer:
I don't think so. This test is one from
loopAmbiguous
It is not
false
for ambiguousness. It isfalse
for being a line - because it is ambiguous.And it is ambiguous because there is a choice to go short way (1 step) or long way (full loop) to get from either
X
to the otherX
Second answer:
I beieve this one comes under the rule
If you follow path the left
X
to the rightX
you eventually get to the bottom right+
and want to go straight ahead. But it is illegal to go straight ahead because+
is ONLY for corners!And if you follow path from bottom-right
X
to leftX
you will find yourself at the 3rd+
in top row and you wont know whether to go left or right. So it is ambiguous.So fails in both directions. So
false
this is not a line.About 10 minutes after posting this, I figured out the reasons why but it was late so I didn't reply. But for future people who are working on this issue and questions about those tests, your answers are invaluable.
You say the first it false because it's ambiguous because you can go the long way or the short way but the short way does not satisfy the rule "Every line "character" found in the grid must be part of the line. If extras are found then the line is not valid." Am I missing something here? This one should be true based on my understanding
@reggaeguitar. Does it matter?
If it is false (because ambiguous) or false (because doesn't use every character) then either way it is false, right?
I still don't understand what exactly you mean by "ambiguous" then. In the fifth good example you can turn left or right when you get to the first cross, how is that not ambiguous?
@reggaeguitar
Yes. What you say is correct when going from LHS 'X' to the RHS 'X'. The line is ambiguous in that direction. But it is not ambigous traversing the line in the other direction (RHS to LHS).
So the line is valid. Because of the rule "Sometimes a line may be valid in one direction but not the other. Such a line is still considered valid."
How is Good line example No. 5 a good line? There is ambiguity in following that line!
Because of this rule:
Got it! Thank you.
This comment has been hidden.
;)
I see now :)
In the Good5 test in C# all of the strings are not the same length. It doesn't say they have to be but "grid" does kind of imply that they will be the same length. Fun Kata though.
Fixed. Thanks.
Ruby translation
Approved. Thanks :-)
Thanks. My rank progress just drifted up about 5%! :)
Hello I need help here, I have error with Preloaded.makeGrid, I am using intellij, and there is not import missing library available, I googled it and I couldn`t find any relevant, the error stack bellow.
Error:(12, 27) java: cannot find symbol symbol: variable Preloaded location: class com.company.DingleMouseTests
this code is specific to the kata and "available" only through it, on codewars. You cannot launch the tests on your IDE without it. Or you need to build a mock class, to emulate it.
Ok Thanks :).
.
hi, about testcase moreEdgeCases. I tested it on my local machine and it return false as expected, is it 1 test contains 2 figures, or 2 different tests? anyway could it be reformatted to make it clear where are the boundaries of test, because now it's not so clear for me
upd may be someone can explain the difference between breadcrumbsTwoWays and moreEdgeCases, they seems the same but one is passed another is not :-(
there are 7 grids in that test method.
Note: state the language you're using, when you have a question... (java)
This description should be more detailed and accurate.
Please let me know which part of the desciption has errors.
Another excellent challenge. I can say without reservation that, to date, your Kata are the most engaging and satisfying I've found on Code Wars. Your test cases are exemplary. Thank you, and keep them coming!
Thanks for your kind comment.
https://www.codewars.com/collections/dinglemouse
Try them all!
Interesting kata. The graph traversal part is the easy part. What makes it more tricy is to determine what nodes are legal dependin on where you came from. Will get back to it.
A begging suggestion, actually it's borderline issue, or so I believe. Please refactor explaination about that 'ambiguity' stuff because it's not clear enough. At least not for guys not natively fluent in English.
this "lookahead" part makes sence only after realizing what it should mean, usually after 'attempt' failing and digging into discource.
also that Hint:
don't help with this 'ambiguity' either. It looks like it suggests to use some pathfinding method.
It should more look like:
BEWARE OF AMBIGUITIES
if after '+' corner symbol line can be proceed in more than one direction the path is considered ambiguous which means: False. so make sure each corner is a corner, not an intersection
example
If you look carefully, you can clearly see a lot of confused warriors in discussion and also a lot of solutions which rigs 'ambiguous' part in 'not very honest' ways. I wish that explaination could help them..
This comment has been hidden.
This clarification was very much needed. Thank you for clearing this up for me.
If there is some way, I want to politely request the author to kindly incorporate this explanation in problem description. Thank you!
Nope, not this time. There is enough information already in the Kata description and Hint.
The pictures above are fine, if you need them, but they are just a different representation of what is already written in the rules.
It's a nice kata, but... what was emphatically not clear for me was that you must turn when you reach a +. Maybe you could point that out?
EDIT: Okay, on a later post you said otherwise, but I'm going to leave this comment as testament to how confusing this is!
It has been asked before but I can not see answer - why would that be invalid? Sure when you start with the lower X then the first corner is ambiguous but if you start with the top one it's very simple because the second '+' must be a turn
Must it?
From kata description:
I believe the bottom branch of that grid is classified as 'extras'
Yes, it must be a corner because it is said that '+' means corners. The other rule, however, in fact justifies why this example is 'invalid'.
No, it's like this:
X
and get to the middle+
there is a choice of 2 paths - go left or straight aheadX
and get to the middle+
there is a choice of 2 paths - go left or right(BTW - The part that says
+
is "only for corners" is not meant to imply the straight ahead path is disallowed. It is only saying that at least one of the outgoing paths from the+
must be a turn. e.g. This is the reason for the 2nd bad-line example. If you think this Kata description is confusing please suggest something better for consideration)."The part that says + is "only for corners" is not meant to imply the straight ahead path is disallowed" & "If you find yourself at a corner then you must turn" & ambiguousness rule = very confusing for me. After one hour reading several times all the comments I finally think that a "+" can really "draws" a path in every direction and even the straight ahead direction has to be considered for the ambiguousness rule. Am I right ?
Hmmm. Maybe the above comment was poorly worded by me years ago... I forget.
IIRC, as the "walker" when you come to a "+" then you MUST turn. There might be a straight ahead path from the "+" (as seen from the direction you are facing) but you cannot take it.
It is best just to read the rules from the Kata description and examples. Those will be right. Whereas sometimes very old comments may have been explaining how it worked way back when it was still evolving in Beta.
This case has been addressed in a post below, but the answer is hidden
I do not understand why this is not valid? There is only one valid path using all the signs. Going directly from X to X is not valid as it does not use all the signs.
EDIT: I think I understood, the fact that there is a choice to go right or down at the beginning makes it anbiguous so invalid. Is that correct?
Even when the original post is hidden, you could expand the replies and see the explanation there.
It seems so.
@bentaye - Correct. Ambiguity is only allowed in one direction. FYI - Here is my reply to same question from 2 yrs ago
Thanks, got it sorted now
This comment has been hidden.
It's explained in the posts below like the one from omiceron.
Another great kata, thank you!
One suggestion though: the 'breadcrumb' tests require a rule that I don't think is adequately covered by the description. "If you come to an ambiguous corner but you've already visited one of the options, then it doesn't count as ambiguous."
People who don't recognise the cultural significance of Hansel and Gretal leaving a trail of breadcrumbs might not realise why those tests count as valid lines, and not ambiguous loops. Is the story widely known in (for example) East Asia?
OK. I changed the description. Thanks for the feedback.
BEFORE
AFTER
Haskell translation
Yes, all the tests are there. And all the logging. ( Based on JS. Sincerely hope that version is complete. )
Looks good to me. Approved :-)
C# Translation added.Please review and approve~
Notice: In java translation, part of
loopAmbiguous Test5
are lost.Please improve it.C# version already added.Approved :-)
Thanks for reporting my Java test bug. Fixed!
I'm passing 23 out of 24 tests, but failing on this one:
It's supposed to be invalid but I do not understand how this is invalid. Seems perfectly valid to me and my code agrees.
EDIT:
I understand it now, this is not valid because there are places where you could turn left or right. I had an incorrect understanding of one of the examples which lead me to a false assumption about what was considered ambiguous.
ex good #5
on 4th + it has a choice, whether to go left or right, its ambiguous, shouldn't it be false?
That one is only ambiguous if you start from the left X.
But the Kata description says:
ohh, now it makes sense
good point
This comment has been hidden.
Because rule from Kata description says:
Because the loop is ambiguous from BOTH ends. This line is ambiguous from only ONE end. Therefore it is "valid".
the fourth "good" line is an example of one that's valid one way but not the other, right?
4th good line is valid both ways 5th good line is valid one way only
oops miscounted
This one
should return true, because it has only one way:
This line is not valid, because it's a lot of characters that aren't part of the line:
So we have only 1 valid solution => true
And why this should return false?
It's possible to draw only one line => true.
JavaScript btw.
RTFM
In all your above examples you get to some junction where you cannot know for sure whether to turn left or right.
That fails my definition of "valid"
@dinglemouse I understand what you are saying but some of the examples seem to contradict this. For example:
How does this not count as ambiguous? There is a very obvious junction where you could turn either left or right. However, if you turn left, you get to a dead end. So if it's only considered "ambiguous" when both paths could possibly reach the end, then that contradicts this example:
There is no junction here where both of the two directions are valid. Thus I'm afraid I just do not understand what meets your definition of ambiguity. (By the way my code passes every test except the latter example, so perhaps its possible we can discuss that, since I have been staring for awhile and do not understand how it could be considered ambiguous. There's only one possible path backwards or forwards.)
EDIT:
Nevermind, I understand now. The first example is certainly ambiguous from one direction, but from the other direction there is no ambiguity. Thus it fits your description where paths could potentially be valid from one direction and not the other.
@RyanGPalmer. Yep. You got it - it was example of:
See other discourse comments here. I think other people struggled with exactly same example.
Python translation!
The random tests are... let's say...:
Would be nice to implement a complete random path generator. Quite a task, though... :o If I find the courage (and if you're interested in it!), I'll try later.
@B4B
Approved - thanks!That thing is because I got sore eyes looking at stupid lines so needed recognisable output to verify the random lines without having to think about it too much...
Been there, done (something like) that with my snakes and spaghetti - not worth the hassle...
thx!
And 3 kyu it is!
This comment has been hidden.
Nice catch.
;)
(note: spaces missing in the 6th suggestion, of course)
@Blind4Basics
well done on identifying these edge cases. 👍Hopefully we see these kinds of tests implemented for this kata.
@B4B. Thanks. I will add your suggested tests as soon as I can. Currently office-hrs :-)
@B4B - OK I added your tests, re-published, and invalidated almost every solution ;-)
BTW one of your examples is incorrect
That one should be
false
, not true. Because even though there seems to be a line it does not match with my description (because when you reach the 2nd+
you do not know whether to turn left or right).Feel free to bump the rank if you think it is warranted.
Cheers, DM
Damn, my own solution isn't valid anymore! x-) I'll have to rework that a bit...
EDIT: ok corrected. I'll do the python translation before trying to bump the rank (but I fear I won't be able to do it anymore after I became "coauthor" :/ )
My original solution got invalidated because of this one test:
I see only one valid path for this solution, but the test fixture expects a
false
result. In@Blind4Basics
's parent comment, he also indicates this should returntrue
.EDIT: this is for the JavaScript version, if that makes a difference.
You surely "overinterpreted" the rules as I did before. Sticking to DM's rules, my three last tests have to return false, actually.
=> if 2 ways are (still) possible at one point, that's not allowed. Even if one of these way is not valid but the other one would end at the
X
.If that's the case, then shouldn't the test below return
false
?if you're coming from the left, yes. But... ;) (not the same rule applied here, actually)
Ah...ok, thanks for clarifying.🙂
Looks like it was in the Description:
@ZED.CWT thanks for approving :-)
This comment has been hidden.
Yes. Good point. I wasn't looking at it quite that way, but I can't see where you are wrong. I will re-write this part as soon as I have time.
yes but by taking the path, you're actually not sure that you'll reach the X: the path might be a dead end. So ambiguous seems good...?
@B4B so what? You are never sure about any line until you get to the other X...
Yea exactly that would be fixable by saying "prefer anything over X" Also if you want to stick to the lookahead (which I myself casually ignored because I perfectly overread that part .-. ) something like that:
(or something more compact) might be a good example (and test) to demonstrate the lookahead-limit :)
I think I figured it out.
If at any point you can go two ways, it's a fail. That can only be at a
+
or at the initialX
.You still have to leave no segment untraveled, and you can't go where you've already been.
Hi @JohanWiltink.
Yes.
AKA: If at any point you can go two ways (but can't tell which way to go) it's a fail. You must leave no segment untravelled
I have been surprised how much trouble people seem to have with this Kata. But at the same I don't much like to explain details how to do every little step because I prefer users should have to think and figure out edge cases for themselves. i.e. solve a problem - not just follow my recipe. I want users to be sure believe they have solved it only to submit and trip over a tricky test case for a case they did not think of!! There is more satisfaction when finally solving such Kata I think.
Unfortunately, too many people have no patience and at 1st hurdle assume my tests are wrong...(not talking about just this Kata - lots of them)
So let me explain this case many are asking about :
a) The most basic valid line is when the
X
are adjacent.Below are valid lines.
b) My Kata requires is there must be only a SINGLE path between the
X
.I hope all can agree the following is not valid because clearly there are 2 ways to get from one
X
to other.c) So now I will just move those end points of the previous picture to show some other invalid ones.
Below are all not valid for the same reason that (b) is not valid.
d) And finally this picture below is NOT VALID because here there are still 2 ways get between the end points.
QED
This is not clear from the description.
It is quite possible that grid is not valid because it is impossible not to leave anything untraveled.
With a lookahead of one step, you can "detect a single "valid" line joining those points". You actually can "tell which way to go".
"Following the line with no ambiguity" seems to refer only to following the chosen line, not to choosing which line to follow.
I agree on not spelling out every step, but if so many people are having difficulty with it, consider you may have fallen into the trap of explaining things ambiguously and yourself only reading into it what you know you intended when you wrote it. It can be quite hard to step outside of yourself and look at things with fresh eyes, without preconceptions. Not thinking about any particular edge case is not a problem, but arriving at a completely wrong interpretation of the problem and then stumbling over an edge case where the answer seems to be just plain wrong is frustrating, especially when the wrong interpretation is consistent with the description as stated.
I think if you change "a single "valid" line" into "one and only one "valid" line", the misunderstandings go away.
Done as suggested. Thankyou for helping to make the Kata description better. :-)
D*mn. I thought wrong.
Going directly from
X
toX
is not a valid line, because there will be segments untraveled. But it does invalidate the other, valid, line. I missed that when I proposed that change.So the definition of ambiguity must be in
just as you intended with that line all along of course.
How can that line be made more clear? "Any possibility of choice when following a line invalidates that line." is what I'm coming up with, but frankly I don't like it all that much either. It should somehow make clear that a valid line has no forks in the road, even if you'll pass over the untraveled segment later anyway (ref ex good 5, where right-to-left has no possibility of forking but left-to-right has that loop).
[edited] got an issue: in randomTest a grid was being reused. I had edited the grid to account for the fact that x and y are swapped (y being horizontal)
also a question: why is
(test example was a bit bigger i think) not legal?
@ZainlessBrombie
Thanks ^_^
Hi again,
Found some time... I have to say I'm a bit confused about some examples:
=> but why? Seems pretty valid to me
=> but why? Seems pretty valid to me and wouldn't true be consistent with this rule of the description:
Sometimes a line may be valid in one direction but not the other. Such a line is still considered valid.
Err... Just realized that is surely because you detect a straight line around a
+
? But in that case, shouldn't the Good5 example rather be considered false because of the+++
section:This comment has been hidden.
Err... If you hide it... ;) OK, seen. I'll keep you posted.
Let's see if I follow your logic, please:
You simply need to return true/false if you can detect a "valid" line joining those points.
should actually be:You simply need to return true/false if you can detect one and only one "valid" line joining those points.
(because of the amibguties cases)Note: that could need some rewording though. Thinking about the
bad5
and beginning on theleft X: turn left, right, right, right, left => other X
could be considere valid but notleft X -> right -> other X
because some characters would remain outside of this path. And so, one valid path is "foundable" but another invalid one is invalidating the line? That sounds a bit weird, actually. :/I think you are overthinking this. I have added a hint to Kata description.
Damn!... X-D
ok, got it, thx. I'll do it later.
@B4B
Have you tried this kata? ;-)
https://www.codewars.com/kata/ascii-games-warning-ice
It's almost the same idea.
This kata is too easy. I solved it using only one line. :
Perhaps I can make a new
ONE LINE TASK
base on it. ;-)Yes. I have seen your one line. And just looking at it was enough to make me feel ill.
1K of madness...
@Voile: Still waiting for the python version! ;p
Hade has the same brain itch with Good5 example. But then I realized it's valid backward!
Very interesting one!! Not finished yet (office time... So not enough time to debug my code yet :/ ), but I believe I know where you may have found the idea and some of the examples... ;-D (it's still waiting for its first Java completion, btw! ;) )
I suppose you are referring to https://www.codewars.com/kata/break-the-pieces-evilized-edition but the truth is it is my own idea and all my own examples. Not copied from anything at all.
Of course using ASCII
+
|
-
to draw lines makes lots of Kata look a bit similar from a distance.