4 kyu
Tracking pawns
305 of 511Nmistrata
Loading description...
Strings
Arrays
Algorithms
Puzzles
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.
Enjoyable kata, keep it up.
Java fork
Java: no random tests.
Sample and fixed test such as
"b4 d6 b6 g6 g3 e4\"
should be added to invalidate solutions that allow 2 pawn moves to be made after 1st attemptAny specific language?
does anyone have a idea why the test is saying it failed, when my results and the test cases are the same ? idk if it's a problem with a format of the return array or something else, but just by looking at the two results side by side, I see no difference between them.
I use python. Im not sure if I can post my code here.
Test1 : [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', 'p', 'p', '.', 'p', 'p', 'p', 'p'], ['p', '.', '.', 'p', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', 'p', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['p', 'p', 'p', 'p', '.', 'p', 'p', 'p'], ['.', '.', '.', '.', '.', '.', '.', '.']] should equal [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', 'p', 'p', '.', 'p', 'p', 'p', 'p'], ['p', '.', '.', 'p', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', 'P', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['P', 'P', 'P', 'P', '.', 'P', 'P', 'P'], ['.', '.', '.', '.', '.', '.', '.', '.']]
Test2 : [['.', '.', '.', '.', '.', '.', '.', '.'], ['p', 'p', 'p', '.', 'p', 'p', 'p', 'p'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', 'p', '.', '.', '.'], ['.', '.', '.', 'p', '.', '.', '.', '.'], ['p', 'p', 'p', '.', '.', 'p', 'p', 'p'], ['.', '.', '.', '.', '.', '.', '.', '.']] should equal [['.', '.', '.', '.', '.', '.', '.', '.'], ['p', 'p', 'p', '.', 'p', 'p', 'p', 'p'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', 'p', '.', '.', '.'], ['.', '.', '.', 'P', '.', '.', '.', '.'], ['P', 'P', 'P', '.', '.', 'P', 'P', 'P'], ['.', '.', '.', '.', '.', '.', '.', '.']]
expected
andactual
are different. you need to compare values side by side and take a closer look.use the
question
tag to ask for help. anissue
is a provable bug in a kataThis comment has been hidden.
Nice Kata but there should be far more random tests.
I agree, in python there are only 13 test cases...
already raised as issue
Description says nothing about how we should handle the promotion case (when a pawn arrives legally at first or last line). I have not completed this kata yet and by reading below comentaries I guess this case doesn't occur but I'd expect description to say a word about that.
The random test in Ruby is bugged. When an invalid capturing move is given, the move after it is expected??
["cxb3", "b6", "b6"] Expected: "b6 is invalid", instead got: "cxb3 is invalid"
["cxd3", "b7", "a2", "b7", "a4", "gxh6", "a4", "d4", "d4"] Expected: "b7 is invalid", instead got: "cxd3 is invalid"
["dxc3"] Expected: [[".", ".", ".", ".", ".", ".", ".", "."], ["p", "p", "p", "p", "p", "p", "p", "p"], [".", ".", ".", ".", ".", ".", ".", "."], [".", ".", ".", ".", ".", ".", ".", "."], [".", ".", ".", ".", ".", ".", ".", "."], [".", ".", "P", ".", ".", ".", ".", "."], ["P", "P", "P", ".", "P", "P", "P", "P"], [".", ".", ".", ".", ".", ".", ".", "."]], instead got: "dxc3 is invalid"
["e3", "a6", "fxe3", "c3", "b3", "a4"] Expected: "c3 is invalid", instead got: "fxe3 is invalid"
Could you give original board inputs? 7 other people have passed this though, are you sure you haven't mutated the input in some way?
Moves: ["exd3", "c5", "e5", "a2", "f3", "g5", "c2", "e4", "c4"] Expected: "e5 is invalid", instead got: "exd3 is invalid"
I printed the moves array and it shows clearly that a capturing move on the first turn should be invalid. I can also pass the kata after submitting a few times, presumbly the bugged test is not generated.
Same stuff happened to me, also forced my way through random tests, but I don't care enough to verify why this happens.
The reference implementation apparently does not check if there is a piece to be captured.
On 'cxd3' as the first move it happily moves the white c pawn to d3.
got the same problem on input ["a4", "dxc6", "gxh4", "axb2", "bxc4", "a2", "axb4", "b2", "c3"] Expected: "gxh4 is invalid", instead got: "dxc6 is invalid"
looks like I fixed tests in Ruby, so now some solutions become invalid. Hope nobody cares a lot.
At least in Python there are no test cases for a pawn moving two units after its initial move.
This was a great kata, I really enjoyed it! I think the description should clarify that a square does not need to be occupied for a capture to be valid though.
where is your logic in this? have u ever played chess? pawns only move foward the only condition for them to move diagonally they have to capture an enemy Piece
or did the autor of the kata do mistakes?
I've fixed tests in Ruby instead of description
Hey, this problem could use a little more clarification. So, are the moves that we are given always going to be in the right order or not? Ie P moves, then p moves, then P moves? Also in terms of incorrect moves, do we always just break off iterating over moves if we find one bad move? Do we try to continue and gather all the bad moves, before returning?
In the description a regex is provided that matches "a-g" but the board is really "a-h" wide.
fixed
(using py)
I have completed the kata, however, I think the tests is not sufficient.
In my codes having passed all tests, I have found several bugs allowing some invalid movess, which means that tests does not cover enough invalid cases.
Already raised as issue
Am I missing something here? It looks to me like there are problems with the examples: If the list/array of moves is: ["e4", "e5", "f3", "c6", "f4"]
I am seeing similar problems in the test-case that is shown in the editor screen. Am I not understanding this correctly?
Mistakes in the description, yes. I updated it, it should be ok, now. Do not hesitated to post again if you see something weird.
didn't read the notes, shame on me. While clicking "attempt" I thought "Oh, forgot to take care of 'en passant' !" Would be nice to make a new kata with all the rules ;) Anyway, good one, tks !
This one is for you, so... ;)
ok :) thanks for the tip !
This comment has been hidden.
yep, that's it. And the link is consistent with that:
"its" = the pawn.
Turns out I was playing chess wrong for my entire life :D Thanks, everything works just fine.
the real question is : who do you play with who couldn't tell you the rules ? :d
Approved
(Not sure why it's ranked
4kyu
, this feels like a slighter harder6kyu
to me)thanks. :)
Nope, not 6kyu... ;)
If you see my solution it's just simple stuff, no more complicated than a certain alien's katas ;-)
Perhaps you meant
7kyu
? ;-)Oof, there goes my self-esteem :)
Java translation, needs a moderator for approval...
thx!
Why used
String[][]
instead ofchar[][]
for the board consisting of justP
p
.
characters?Just because... why not? ;) This is a fully arbitrary (almost) choice I made (I confess, that was easier this way considering the kind of implementation I had on my side... ;o )
OK, I'll adopt this kata too...
Completed in python. Very good Kata, thanks. I can feel a bit of refactoring coming on.
done... ;)
Great kata! But as it stands, the first one of the two given unit tests fails to compile.
Other than that excellent!
Thanks for the feedback! the test case was missing quotations to identify each pawn move as a string, oops. It has been fixed: test.assert_equals(pawn_move_tracker([e3, d6, e4, a6]) >>> test.assert_equals(pawn_move_tracker(["e3", "d6", "e4", "a6"])
Also - I suggest adding the 'strings' and 'arrays' tags.
Enjoyed this kata. My only critique of it is that I wonder if a FEN string would have been better to use as a structure for the position on the board versus a 2D array (although I gather one could argue the kata's main testing point is the warrior's competence with 2D arrays to begin with...).
Regardless...well done!