5 kyu

How many Wagons Are in the Train?

Description:

You are in a Train that is permanently moving in a circle. The Train is looped: The head is connected with the tail and you can go from one to another directly.

Every wagon has a light, you can switch it on and off if you wish.

Count the number of wagons!

You can move between wagons as you wish.

Constraints:

After you count the wagons, the lights in the train should be in the initial state they were in. But at the end you don't need to be in the same wagon where you started.

Use the implemented Train methods:

public boolean isLightOnInCurrentWagon()

public void switchLight()

public void goToNextWagon()

public void goToPreviousWagon()

Train notation "1 : 0 : 0" means that you have a train with three wagons. The light is on in the first wagon and off in the other two.

Algorithms
Puzzles
Lists
Linked Lists

Stats:

CreatedDec 16, 2019
PublishedDec 16, 2019
Warriors Trained631
Total Skips39
Total Code Submissions1031
Total Times Completed115
Java Completions115
Total Stars15
% of votes with a positive feedback rating92% of 30
Total "Very Satisfied" Votes27
Total "Somewhat Satisfied" Votes1
Total "Not Satisfied" Votes2
Total Rank Assessments11
Average Assessed Rank
5 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • sgerodes Avatar
  • el-f Avatar
Ad