Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
@geoffp. Oops. My bad. Thanks.
Thanks. The C++ translation seems to be OK now.
The new test case had a train "Bxxx"; I guess that was meant to be "Bbbb" and have changed it accordingly.
Thanks for additional info. I've added another test case (equivalent to your "simple test")
These translations are OK:
C#
,Java
,Python
,Ruby
This translation is NOT OK:
C++
~
Unfortunately the person who created the C++ translation seems no longer active.
My C++ is rusty but I'll see what I can do about it.
EDIT: Fixed / Hacked? / Anyway, now C++ is working
Hmm, it seems that the Java and C++ versions of the kata are different in this respect. In the Java reference solution, the
Train
class has a variablewhose initialization to 0 will ensure that every train moves on the very first turn. (A separate boolean variable indicates whether the train is an express.) But in the C++ version this becomes
and we have the code
so that newly-created non-express trains that start on stations have to wait one turn before moving.
A simple test that distinguishes these behaviours is (in C++)
which should give the result 1 (both trains try to move to position 3 on the first turn). But the current reference solution in C++ gives 2 (the station delays the A train by one turn).
No no no. You are reading too much meaning into next and immediately ...
The rule is really simple:
If the initial train position (i.e. the engine) at the beginning of the "game" happens to be exactly on a station
S
, then the train will NOT wait at that station. Its first move will be to leave the station. i.e. The behavior of suburban and express trains is exactly same in such a scenario.The "master" version (Java) of my Kata works correctly for this rule. I've added a new fixed test case to confirm it.
EDIT: Added new fixed test to all languages to check "Start exactly on the station" (for both suburban and express trains)
This tripped me up, too. When starting on a station, the train, if not an express, leaves at the next move, i.e. not immediately. But an express train ignores stations, so it leaves immediately. This implies that a non-express train that starts on a station will always be (at least) one step behind where it would have got to if it were an express. Unfortunately, there is no fixed test for this behaviour, but it comes up in the random tests sometimes.
That's specified in the notes:
Added in all languages.
Added a note in the "Language" section of the description.