You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: exercises/concept/train-driver/.docs/instructions.md
+25-23Lines changed: 25 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,17 @@
1
1
# Instructions
2
2
3
-
Your friend is a train driver and has to drive cargo trains between cities.
4
-
Although your friend isn't amazing with handling the computers and would like some help with it.
5
-
Your friend would like your help organizing the train and correcting mistakes in the data.
3
+
Your friend is a Locomotive Engineer who drives cargo trains between cities.
4
+
Although your friend is great handling the trains, they aren't amazing handling the logistics computers and would like your programming help organizing the train and correcting mistakes in the data.
6
5
7
6
```exercism/note
8
7
To practice, use the rest or spread operator to solve each of the tasks below.
9
8
```
10
9
11
10
## 1. Create a list of all wagons
12
11
13
-
Your friend has been keeping track of each wagon identifier. Although they are not sure how many wagons and would like the data to be returned as an array.
12
+
Your friend has been keeping track of each wagon identifier, but they're never sure how many wagons they are going to have to process at any given time. It would be much easier for the rest of the logistics program to have the data to be returned as an array.
14
13
15
-
Implement a function `getListOfWagons` that accepts an unknown amount of positive integers that contains the id of each wagon.
16
-
It should return an array of all the wagon ids.
14
+
Implement a function `getListOfWagons` that accepts an unknown amount of positive integers which are the IDs of each wagon.
## 2. Move the first two elements to the end of the array
24
22
25
-
Now that you got a general feel for handling your friend's data.
26
-
The train id system works by the locomotive having id number one and the rest of the wagons having a random id.
27
-
Your friend had to connect two new wagons to the train and forgot to update the id system.
28
-
Now the first two wagons in the array have to be moved to the back of the train.
29
-
Your friend would like you to move the first two wagons to the end of the array.
23
+
At this point, you are starting to get a feel for your friend's data and how it's used in the logistics program.
24
+
The train ID system works by assigning the locomotive an ID of `1` and then assigning the remainder of the wagons a randomly chosen ID greater than `1`.
25
+
26
+
But then your friend had to connect two new wagons to the train and forgot to update the system!
27
+
Now the first two wagons in the `array` have to be moved to the back of the train, or everything will be out of order.
28
+
Your friend would be really grateful to you for fixing their mistake.
30
29
31
30
Implement a function `fixListOfWagons` that accepts an array of the id of each wagon.
32
-
It returns an array where the 2 first elements are moved to the end of the array.
31
+
It `return` an `array` where the 2 first elements repositioned to the end of the `array`.
Your friend realized that all data wasn't added and found another array which contains the missing wagons.
43
-
Your friend would like you to add the missing values to the array.
44
-
All they can remember is that the missing values should be placed after the locomotive in the array.
41
+
Uh-oh. some wagons seem to have gone missing.
42
+
43
+
Fortunately, your friend just found another `array` which appears to contain the missing wagon IDs, and would like you to add them into the main wagon ID `array`.
44
+
All they can remember is that the missing values should be placed directly after the designated locomotive.
45
45
46
-
Given this new information, write a function called `CorrectListOfWagons` that takes two arrays which have the id of each wagon as an argument.
47
-
The second array should be added after the first element of the first array.
46
+
Given this new information, write a function called `CorrectListOfWagons` that takes two arrays which have the IDs of each wagon as the arguments.
47
+
The wagon IDs of the second `array` should be added into the first `array` directly after the locomotive (ID 1).
0 commit comments