• Actual and expected values are flipped in Python random tests.

  • The function name should be in snake_case in Ruby.

  • In python for some valid integers the expected result is nan.

  • In python function name should be snake_case.

  • This kata was published in 2013. Ranks have deflated since then, and they cannot be changed.

  • I totally agree. This was much too easy for a 4 kyu.

  • Yeah, you're right about the verticals & diagonals, but I guess it could work by assuming that the letters of the train proceed along the track in whatever the positive x/y direction is. Maybe nobody else even made this mistake!

    Edit: Ah, fair enough. I missed that detail!

  • What you're meant to assume (it's not stated explicitly) is that ...

    Actually, it is stated:

    • A train that looks like zzzzzZ is travelling clockwise as it passed the track "zero position"
    • A train that looks like Zzzzzz is traveliing anti-clockwise as it passes the track "zero position"
  • This should probably be a five kyu.

  • Right, what I didn't get from the instructions is that the direction is only a function of the string representation of the train, and not a function of the string representation plus the train position.

    If I say, "You can tell which way the train is going based on its engine" and then give you the position, you can imagine different scenarios like this:

    Train "aaaA" at position 6

    /--aaaA--\
    |        |
    \--------/
    

    Train "aaaA" at position 14

    /--------\
    |        |
    \--aaaA--/
    

    What you're meant to assume (it's not stated explicitly) is that the string representation of the train is how it would be laid out at the zero-position, and then you can imagine it running around the track to arrive at its orientation at the given starting point (in example two this would lead to a reversed train of Aaaa). What I was imagining was that the train would be laid out visually, according to the string, AT its starting point. In that case it would require another step of figuring out how the train is pointed based on where on the track it is, and make the kata slightly more difficult.

  • Kata already says:

    The engine and carriages use the same character, but because the only engine is uppercase you can tell which way the train is going.

    and

    All tracks are single continuous loops

    That's all you need to know.

    ALL trains go "forwards" (with the engine at the front!). I thought that was so obvious I did not ever write it ;-)

    Of course, just looking at aaaaaA on a complex track, it will be difficult to judge is that train really going "clockwise" or "anti-clockwise" as it passes the track "zero position".

  • I really enjoyed this kata, thank you!

    One minor suggestion, and a part that I got stuck on for a few minutes:

    When determining the train's direction on the track (positive or negative), knowing whether the first or last character is a capital letter is enough.
    This is fine, but it was a little counterintuitive to me since if you know the position and the visual orientation of the train, it could be going in either the positive or negative direction, depending which part of the loop it's laid out on...

    If that's not clear, imagine a simple square-shaped loop. If my train aaaaA is on the top part of the loop, visually it's going forwards. If it's on the bottom part of the loop, it's visually going backwards. It's a litte weirder for the sides, but the same idea applies.

    Not a big deal, but I thought I'd mention it in case it makes the instructions clearer for anyone else!

  • I'm failing only some numbers with length 15. I've tried printing the solution in the terminal, and I get the expected answer, yet the returned answer isn't what my code is. Am I missing something here?

    For example:
    Random digit tested: 5146244053829671: 0 should equal 3

  • I don't mind this style of Kata (as I commented on the previous one in the series, Car #2). However, this one has a very poor description, many hidden assumptions, and at least one test case that's inexplicable to several users (See boy1255's comment about AverageConsumptionsAfterBraking below).

    Since the author hasn't responded to this in years, and has indeed deleted his account... I would say that this kata should be retired.

    The other two in the series aren't so bad. They might be worth keeping.

  • Loading more items...