6 kyu
Snakes & Ladders
287 of 1,054dinglemouse
Loading description...
Arrays
Fundamentals
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.
There are snakes at the end of the
board
in Go tests. I've created a fork that fixes this bug. Could someone approve it?"There are no ladders on the starting square, and there are no snakes on the final square." So why does the random tests have a snakes on the final square? For example: board [0 0 3 0 4 0 0 9 0 0 0 0 0 0 7 0 0 0 0 3 0 0 0 0 0 0 0 -1 0 -4]
The Go translation is incorrect. It's mentioned in this open issue, but nobody has fixed it yet.
Hello EPiph,
In the example I have listed the board is ten (10) squares in length (i.e. - the last index is 9)
5 (five) + 5 (five) = 10 (ten) and therefore if you are on square 5 (five) and you throw a 5 (five) then you cannot make a move
I therefore do not consider this issue to be resolved and I maintain my request for yourself to review all of the tests within this challenge
In the example you listed the board is 11 elements long.
It was much quicker to review your issue than to review all tests as requested.
This issue is resolved. Please do not raise it again without very thoroughly reviewing your logic/code/assumptions.
Hello awesomead
I maintain my position that I believe that the author of this challenge should review all of the tests within this challenge
I have given a coherent and logical demonstration of why I believe the example test is flawed and it must be noted that I have observed that there are several other comments on this challenge to the same effect as my own
The only other thing I would like to say is that if you do not have anything nice to say then do not say anything at all
Please don't post solution code in the discourse (without a spoiler tag) since everyone can see it!
The sample tests are just that: sample tests. The submission tests (which are run when you press "attempt") are different and usually much more extensive. Passing one does not mean you'll pass the other.
I'll say this again: please throughly review your logic/code/assumptions before posting. As the saying goes, more often than not the error sits between screen and chair.
EDIT:
Please don't edit previous posts to which you have already received responses. At best, it's considered incredibly rude and bad etiquette. As for your new edit/remark: If I had not said anything, you'd have most likely posted 3 more questions/issues by now, all based on the same flawed assumptions.
I maintain my position that I believe that the author of this challenge should review all of the tests within this challenge for the coherent and objective reasons I have given
If you do not have anything nice to say then do not say anything at all and, given that you clearly do not understand this, I have now Blocked yourself on CodeWars
You are formally advised to not attempt to make any further contact with myself again at any point in time in the future
I'm formally what? Where are we, Parlament? The House of Karens?
The "coherent and objective" reasons you claim to have made were nothing of the sort. In fact, I debunked your flawed assumptions openly and unequivocally. The fact that you are still maintaining that you have some sort of issue to raise, after being told twice by two users that you were in error, means you're either obstinate beyond reason or simply a bit slow on the uptake. Neither of those attributes makes you entitled to not be contacted by my royal self or anyone else for that matter.
Calm yourself and stop spamming the discourse.
If there is a moderator of CodeWars that is viewing this comment then I would be very grateful if you could please look to delete this entire conversation trail from the Codewars website
Hello,
why should it be deleted?
Hello Blind4Basics,
I did not feel my request for the author of this challenge to review the tests to be unreasonable, but I would like this conversation trail to be deleted as the conduct of others who have responded has upset myself a great deal
I would therefore like this conversation trail to be deleted in its entirety so that I can try to forget about this upsetting episode, which I have to say has greatly discouraged myself from making further comments/enquiries in the future
This all would have been much simpler if you'd simply said "ok thanks for pointing out where I was wrong" instead of repeatedly doubling down like a buffoon.
Your first raising of an issue was a reasonable mistake. You failed at counting. It happens. But after having the mistake clarified, every further repetition of your request to have somebody review hundreds of lines of code simply to satisfy your refusal/inability to realise your mistake is by definition unreasonable.
This tells me a lot about what you believe the world you live in to be like. A reasonable person would simply refrain from visiting this discourse again to avoid the reminder of their past folly. You, however, expect the entire world to modify itself to save you the trouble. Heads up: it doesn't work like that. In fact, and in all seriousness, I would formally advise you to take heed of this fact in your future interactions with the greater world wide web.
I actually wasn't notified about these messages... so only seeing them now...
Sorry if I closed your issue without too much of an explanation yesterday, I thought what I said would be enough to point the right direction. I only recently got the privilege to close issues.
Hello,
Can the author of this challenge please review all of the tests within this challenge
The answer to the example test should be 9 (nine) but the challenge is seeking the answer of 10 (ten) which, as per the below analysis, I believe to be incorrect
dice = [2,1,5,1,5,4]
board = [0,0,3,0,0,0,0,-2,0,0,0]
Throw #1
Index at Start of Turn: 5
Thrown: 2
Move To Index: 2
Land On: 3 (a ladder)
Index at End of Turn: 5
Throw #2
Index at Start of Turn: 5
Thrown: 1
Move To Index: 6
Land On: 0
Index at End of Turn: 6
Throw #3
Index at Start of Turn: 6
Thrown: 5 (a higher number than is needed to reach the final square, so no movement)
Move To Index: 6
Land On: 0
Index at End of Turn: 6
Throw #4
Index at Start of Turn: 6
Thrown: 1
Move To Index: 7
Land On: -2 (a snake)
Index at End of Turn: 5
Throw #5
Index at Start of Turn: 5
Thrown: 5 (a higher number than is needed to reach the final square, so no movement)
Move To Index: 5
Land On: 0
Index at End of Turn: 5
Throw #6
Index at Start of Turn: 5
Thrown: 4
Move To Index: 9
Land On: 0
Index at End of Turn: 9
This is the example explained in the description?
On step 5 you can move 5 places forward, ending the game...
Hello EPiph,
In the example I have listed the board is ten (10) squares in length (i.e. - the last index is 9)
5 (five) + 5 (five) = 10 (ten) and therefore if you are on square 5 (five) and you throw a 5 (five) then you cannot make a move
I therefore do not consider this issue to be resolved and I maintain my request for yourself to review all of the tests within this challenge
Hello CAdams747,
I think you might have miscounted, as the example you gave is actually eleven (11) squares in length:
So therefore the description seems accurate to me. Do you agree?
Hello Kacarott,
In direct answer to your question, I am happy to accept that "[0,0,3,0,0,0,0,-2,0,0,0]" has eleven (11) numbers in it
With that being said, in the several attempts I have had to try and resolve this challenge I have had instances where I have passed the example test but then the solution then fails the random tests and then if I tweak the solution to seemingly pass the random tests I have then found that my coding fails the example test - and from reading the Comments linked to this challenge I have gained the perception that there have been a few others that have encountered similar issues
When I work on a challenge and my coding is unsuccessful, I initially work to the premise that there is a flaw in my coding - but when I am reasonably satisfied that my coding is correct I then review the Comments to see if others are encountering similar problems, which may indicate a flaw in the programmed tests
In this instance, I have perceived from reading the Comments linked to this challenge that there were indeed others who were encountering similar issues - which re-inforced a perception that there may potentially be a flaw in the programmed tests
On that basis, earlier today I respectfully asked the author of this challenge to review the tests that had been programmed into this challenge - but I regret to advise that I have received some unbecoming comments from some CodeWars users in response to that respectful request to the extent that I have taken the measure of blocking two CodeWars users (which I think, prior to today, is an unprecendented measure)
I still do believe that the author of this challenge should give all of the programmed tests a 'once over' to ensure that all of the programmed tests do contain the correct results - but I obviously cannot compel the author of this challenge to do that
From what I can see, you appear to be a moderator on the CodeWars website and, on that basis, I would therefore be extremely grateful if you could please delete any conversation trails that I have initiated from this challenge so that I can put the events of today behind me
Codewars is not in the business of censoring conversations. This is not a monologue, others are involved in this conversation too. I don't think you have the right, nor should you have the audacity to make such a request.
@CAdams747, excuse me for the intrusion. I'm picking up clear signs of a neurodevelopmental disorder from the prosody and information packaging in your writing; for your privacy I won't say which one and I suggest you don't either. I understand this conversation is upsetting for you. I strongly suggest that none of the following are going to help:
The best you can do is to set this issue down in your mind. You are not going to convince other users here of your viewpoint because they have their own good reasons for believing what they do, and if you are not likely to change your own mind then it's best you just leave this one as it stands.
Hi CAdams747
Yes, writing a solution which passes sample tests only to fail the full tests is actually quite a regular occurance on Codewars. This is because the full tests contain a full set of randomised tests and often many more fixed tests to ensure the validity of a solution.
Due to this, it is actually very common for solvers to become convinced that there is a problem in the tests, instead of in their code. This is why you will often see many comments in the discourse about this, but in my experience, 99% of the time it is just a problem with the solvers solution in a way they hadn't realised.
However it is of course possible for a kata to have errors, and we want to take this seriously, but if authors were required to "do a once over" anytime a solver felt like their solution was correct, there would be an unendless amount of work to do, because as I mentioned, this happens very often. This is why longtime users on this site tend to only take issues seriously which directly show a problem. Usually this means showing an input which was tested, and showing that the result that the tests expect is actually wrong.
Without this direct proof, requesting that a kata tests be checked over is a bit unreasonable. Keep in mind that all kata are checked carefully (or, should be) before being approved, and most real issues are found within the first few solves (while this kata already has hundreds of successful solves). Now, the issue you raised did try to show a direct proof, which is good, the only problem was that the proof had a flaw. I believe this is why the other users were giving you a hard time, because rather than simply acknowleging the mistake (which we all make) you kept insisting that your solution was correct.
So, with that all being said, I encourage you to continue trying to solve the kata, and keep track of the inputs being tested with. If you do run into an input where you are sure that the expected solution is wrong, then please raise an issue with the details, and either the kata author or someone else will look into it and fix it.
As for deleting the conversation, this would involve deleting other users posts too which is also not a reasonable request, unless they violate terms of service or similar (and from what I see, nothing of that kind has happened here). Posts on Codewars are fairly permanent, which hopefully has the positive effect of people thinking through their messages more carefully :)
@CAdams747
That's ME. I wrote this Kata. I wrote that example.
Actually, I already saw you original question yesterday, and I already I saw that EPiph correctly responded to it, so I upvoted the reply.
In my experience, before making raising an issue it is best to STOP and then check how many times a Kata has been solved. Given this is a 7 yr-old Kata example with 982 previous solutions the odds were literally almost 1000:1 that your "issue" would be self-inflicted, even if you couldn't see the reason.
Anyway, I felt compelled to give that example the once over, so I did, and it LGTM.
Hello *Kacarott
In broad principle, I am in agreement with the general overtone sentiments of your post
but
Before elaborating further on the previous sentence, I wish to make the following clear to all CodeWars users that at the time of sending:
(a) I am inside the Top 900 on the CodeWars Leaderboard
(b) I have completed nearly 1900 Kata
and
(c) Having reviewed all of my seldomly made Comments on this website, I have made the request for a challenge author to review their programmed test less than ten times and, to give a rough calculation of the frequency of request "10 / 1900 = 0.53%"
With regards to my attempts to solve this Kata:
When my coding and it passed the random tests it was then failing the example test
and
When I tweaked my coding and it passed the random tests it was then failing the example test
As I have stated in a previous post:
When I work on a challenge and my coding is unsuccessful, I initially work to the premise that there is a flaw in my coding - but when I am reasonably satisfied that my coding is correct I then review the Comments to see if others are encountering similar problems, which may indicate a flaw in the programmed tests
In this instance, I have perceived from reading the Comments linked to this challenge that there were indeed others who were encountering similar issues - which re-inforced a perception that there may potentially be a flaw in the programmed tests
I think that Point C from the above outlines that I do not make a request of a challenge author either frequently or lightly
I am not interested in changing anyone else's opinion - as my faith in both humanity and society decreases with every day that passes because of conduct like that of some of the other CodeWars users - but during this conversation trail:
(a) In a now deleted conversation trail I have been trolled as a 'buffoon'
and
(b) In a post which is still on this challenge at the time of posting, I have been trolled as someone having a 'neurodevelopmental disorder' which is, at best, insenstive to people who genuinely have such a medical condition
If you do not delete all of the conversation trails that have been initiated by myself then in my considered personal opinion:
(a) You are implicity saying that the above two examples are acceptable conduct both on CodeWars and in society in general
(b) You will seriously and heavily discourage people from making (acceptable) Comments on CodeWars going forwards
Hi CAdams747,
Codewars is full of amazing people. You can make them your friends with your amazing coding skills. Learn from them, even if it's the hard way, but always remember to accept your mistakes.
You're like a dog with a bone, seriously. Absolutely incorrigible. Let me try one final time to illucidate you as to what exactly everyone but yourself is talking about:
TL;DR: Your first comment was reasonable, albeit erroneous. Every further comment you made after your error was pointed out to you was unreasonable. Every further comment you wrote in this discourse proves that further.
We've tried with facts, we've tried with sarcasm, we've tried with snarkiness, we've tried with exaggerated politeness. None of this has been able to pierce the veil of your obstinacy. Please, just stop.
This comment is very problematic:
because:
"You are implicity saying that ..."
), in name of another person. Don't do that. You can only speak for yourself.I think you have a major issue communicating with other people.
Hello saudiGuy,
I am in broad agreement with the principle of what you are saying and I genuinely hope that CodeWars is full of amazing people
In this regard, I wish to express my sincere compliments to yourself because I have perceived your post as an attempt to try and:
(a) Portray that CodeWars does have some amazing people on it (which I hope it does)
and
(b) Restore my faith in humanity and/or society - but the experience of this conversation trail has seemingly only drawn out the 'non-amazing' people who also unfortunately frequent this website
As far I am concerned, the crux of this conversation has been:
(a) I respectfully asked for the author of this challenge to review the tests that were programmed to this challenge - and, in this regard I would like to thank dinglemouse for their reply and for taking the time to give the example test the 'once over'
(b) All I initially feel I got for my troubles was to be trolled by one CodeWars user trolling myself as a 'buffoon' and another trolling myself as someone with a 'neurodevelopmental disorder' - and I have blocked four CodeWars users (to date) as a result of this conversation trail
(c) The first polite/constructive (i.e. - non-abusive) reply I got was from Karacott who, using facts and constructive language, outlined that the example Array had eleven items and not ten
and
(d) In my first reply to Karacott, I acknowledged that the Array "[0,0,3,0,0,0,0,-2,0,0,0]" had eleven numbers and not ten (i.e. - I admitted that 'mistake')
With that being said, my experience of this challenge as I have been attempting to solve this has been:
---> When I got coding to pass the example test, the coding then failed the random tests
and
---> When I got the coding to pass the random tests, it then failed the example test
In closing, I can only re-iterate:
(a) When my coding is unsuccessful, my initial premise is to presume that there is a flaw in my coding
(b) If I am reasonably satisfied that my coding is sound, I check the Comments of the challenge to see if others are having (or have had) issues with the challenge
...and only if the challenge shows evidence of people expressing problems and/or issues...
(c) I respectfully ask the author of the challenge to review the tests that have been programmed within the challenge
In this regard, I have taken Step C less than 10 times, and I have completed nearly 1900 Kata - and so it should be apparent to all concerned that I rarely take this step and I do not do it lightly
Just admit you dropped the ball and move on
This may be of interest to you.
Hi again, I notice you've mentioned several times that you've solved 1900 katas. I believe the Codewars community would extend the same respect to new users who seek help. Conversely, the community could challenge top users if they're found cheating. You can't doubt their integrity, dedication, and hard work. However, they might get frustrated if someone repeatedly argues with them over unfounded accusations.
But for now, let's put all of this aside. Remember, on this platform, we're all essentially strangers. We go by usernames, not real names. Imagine that no one has said anything to you.
Take a moment to cheer up and step outside for a breath of fresh air.
Hello saudiGuy,
Ultimately, I completely agree with your overriding sentiment that it is time to put this sad, sorry and upsetting episode in the past and move on
The only reason I mentioned that I have solved nearly 1900 Kata on CodeWars was to try and portray:
(a) By virtue of the number of Kata I have solved, I must logically be a reasonable programmer
(In this regard, I do not claim to be the best programmer in the world and there is absolutely no doubt that there are far, far better programmers than myself just on this website alone)
and
(b) I rarely ask the author of the challenge to review the tests that have been programmed
(I am generally wary of leaving any Comments for fear of a 'keyboard warrior' response like has been seen in this conversation trail)
With regards to the aspect of authenticness:
(a) I can very safely say that I have solved every Kata on this website honestly
and
(b) I have no basis to believe that any other Codewars user may be solving Kata dishonestly (and I think I would share the same contempt as yourself for anyone that is using this site dishonestly to gain false credit)
As we have now both said, it is now time to consign this sad, sorry and upsetting episode to the past
and
I think it will probably be a very, very, very long time before I even think about making another Comment on Codewars
I know he's not going to see this but just for the record, having a neurodevelopmental disorder is not derogatory. That was a sincere attempt to help.
A narcissist cannot be reasoned with. Next time we should just ignore such users.
Anyway, why can't we see the profile page of a user that mutes/blocks us? Seems a bit too much safe space for such users, pitty.
Related: https://github.com/codewars/codewars.com/issues/2418
Edge case testing is inconsistent between languages. Snakes on the final square appear only in Go. According to the description, this case seems to be valid.
Hmm - That's not intended. I updated the description. The
Go
translation is in error.Scala translation
Approved :-)
This was a fun one, thanks :)
good one :D
Python translation: https://www.codewars.com/kumite/64024f60ca1e64003e22bbc8?sel=64024f60ca1e64003e22bbc8
Approved. Thanks!
This comment has been hidden.
The reason why your solution didn't pass is because you modified the input array
dice
, so after the first test in the section it was exhausted.Thanks for noting that out, I changed the tests so they won't be modified after each function call, now your solution should pass.
Hmm, but I failed the same test case where I was just modifying the board by updating our position in it with an "x". I assumed to solve this we'd need to update one of the parameters... but I suppose that only matters if you're doing it recursively. I coulda just tracked my position with a variable and a while loop or something and it probably woulda been simpler.
What did you mean by 'exhausted' though.
"exhausted" means "the array has become empty, and then that empty array has been used for the next test case, although it was supposed to be the same as before the first test".
Ah I see thank you for explaining it and fixing it. So me using pop() was the problem. I'll keep it in mind that some problems may not play well with mutating an array.
Very fun. I encourage more people to try this one!
JS fork with upgrading the test framework;
Go fork fixing the issue below by akar-0 (link)
JS fork approved
Go fork also approved
Tests in Go are wrong: they expect one to continue until there is no throw left though one has reached the end:
Should be fixed in this fork, please check it up
Fixed
Even I'm facing the same issue with broken go tests, (11/100), (53/100), (56/100) and (77/100) numbered test are throwing very similar errors, though my code is working properly.
@SinisterSup, your solution supposed to stop when you get exactly on the final square (not paying attention to the snakes/ladders it has), i.e. if on the next turn you get exactly on the final square, you has to return it, ignoring the value of that square (0, snakes or ladders).
Your code, however, doesn't stop after reaching it, and continues the turns.
board = [ 0, 2, 0, 0, 0, -2, 0, 0, 0, 0 ] dice = []
Expected output is 6?
Sounds like a bug. Which language is this please?
JavaScript
In JS it seems all the snakesAndLadders section of tests is buggy:
By adding those exceptions the tests pass normally.
I also managed to resolve it by not mutating the dice array
What means No Dice?
Means you have no dice.
Means you have no throws, so by rule above the game is over before it begins.
Means just edge case.
Go random tests do not seem work properly. In a case, when "could stop here". My code ran directly returns "actual" result rather than "expect"
....
This comment has been hidden.
Without more information noboby can reproduce anything
Please capture some logging from a test you think is wrong and provide:
board
,dice
expected
,actual
Thanks
This comment has been hidden.
C# Translation added.Please review and approve~
Approved :-)
Nice kata!
Nice comment!
:D :thumbsup:
@gabbek
thanks for approving :-)I really enjoyed solving this Kata. Also, I think it is fine in context of the story that certain checks are not needed (for example starting with snake, ending with ladder, letting a snake move us before the initial position etc.)
Perhaps in a future Kata we could write a function that generates a valid board? :)
I like Snakes & Ladders.When I was a child,I always play this kind of board game by myself.
(Because no friends)If the board is 2-dimension would be better.Because it's a board not a line. Otherwise this is a good kata.IMO the game is linear however you look at it (e.g. squares 1,2,3,4...100 are 1,2,3,4..100 no matter how you represent them).
Of course in real life it is a 2D sheet of cardboard instead of a very long strip, which has the advantage of fitting into a box better plus you can play it on a table instead of only in the hallway :-)
~~
But I may use your suggestion for a future variation of this Kata.
Cheers.
There is no reason why the board couldn't start on a ladder or end on a snake (making it unwinnable), or why a ladder or snake couldn't end on a ladder or a snake. They're perfectly reasonable edge cases.
This would invalidate some solutions, including your own :P but the board remains decidable.
The reason is I wanted my board to resemble a board as in the real-life game, where I don't think those kind of cases that you suggested exist.
So there is a reason. :P
I'm just not familiar enough with the actual game I guess. :] (Closest I can think of is Donkey Kong? But, wrong animal.)
Translated to
JavaScript
https://www.codewars.com/kumite/582b0b6cbbbc7473ff000228?sel=582b0b6cbbbc7473ff000228
:-)
:-)
Hi, just a hint: First submit i got one single random test error, second/third not - perhaps somethings wrong or (edge- testcase) missing here (and bug in my code?), haven't looked for more details, not easy to see errors without checking the input and dice sequence...
Maybe it's a coincidence, but I as well had trouble with one test.
Oops. I found the board has somehow generated a ladder that leads directly to a snake. That's not supposed to happen. See that
+9
below.My solution didn't expose this. Yours did.
I'm taking this Kata offline until I fix it. Thanks!
All fixed. Should be good to go again :-)