4 kyu

Tracking pawns

305 of 511Nmistrata
Description
Loading description...
Strings
Arrays
Algorithms
Puzzles
  • Please sign in or sign up to leave a comment.
  • ahmet_popaj Avatar

    Enjoyable kata, keep it up.

  • LosBlobbos Avatar

    Java fork

    • Random tests
    • added fixed test of 2 step move
    • Updated to Junit 5
  • Madjosz Avatar

    Java: no random tests.

  • ejini战神 Avatar

    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 attempt

  • PocketPancake Avatar

    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'], ['.', '.', '.', '.', '.', '.', '.', '.']]

  • hobovsky Avatar

    This comment has been hidden.

  • RealKenshiro Avatar

    Nice Kata but there should be far more random tests.

  • akar-0 Avatar

    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.

  • myri11 Avatar

    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"

  • uttumuttu Avatar

    At least in Python there are no test cases for a pawn moving two units after its initial move.

  • reggaeguitar Avatar

    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.

  • Philip Wright Avatar

    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?

  • kgimpelson Avatar

    In the description a regex is provided that matches "a-g" but the board is really "a-h" wide.

  • tmxk Avatar

    (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.

  • TickleMeElbow Avatar

    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"]

    [[".",".",".",".",".",".",".","."], ["p","p",".",".","p","p","p","p"], [".",".","p",".",".",".",".","."], [".",".",".","p",".",".",".","."], [".",".",".","P",".","P",".","."], ### Why has this piece been moved? Isn't this column D, not column E? [".",".",".",".",".",".",".","."], ["P","P","P","","P",".","P","P"], ### Why is there no '.'? [".",".",".",".",".",".",".","."]]

    I am seeing similar problems in the test-case that is shown in the editor screen. Am I not understanding this correctly?

  • lukophron Avatar

    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 !

  • user6246903 Avatar

    This comment has been hidden.

  • Voile Avatar

    Approved

    (Not sure why it's ranked 4kyu, this feels like a slighter harder 6kyu to me)

  • Blind4Basics Avatar

    Java translation, needs a moderator for approval...

    thx!

  • Blind4Basics Avatar

    OK, I'll adopt this kata too...

    • description updated with some minor things (and a note about the "en-passant" rule)
    • Java version coming in the next days.
  • daddepledge Avatar

    Completed in python. Very good Kata, thanks. I can feel a bit of refactoring coming on.

  • ChristianECooper Avatar

    Great kata! But as it stands, the first one of the two given unit tests fails to compile.

    Other than that excellent!

  • kphurley Avatar

    Also - I suggest adding the 'strings' and 'arrays' tags.

  • kphurley Avatar

    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!