ℹ️ For detailed information about the contest, check out devadvent/readme
Winters at the North Pole can be harsh, which not only affects the elves, but also technology. Some of the train wagons that are used to transport materials, presents, etc. in and out of the North Pole are really old. In this harsh weather, faulty brakes can cause accidents on the tracks.
That is why you're helping the head mechanic elf to check whether today's train wagons are up to code or not.
Today's puzzle is a bit more complicated. But I can give you a hint to the prize 🏆:
You need a special kind of wallet to receive it 👀
The concept that is being treated today is called a Singly Linked List. If this is new to you, you might get through this puzzle faster if you read up on it.
The train is composed of:
- Locomotive which is attached to a wagon
- Multiple wagons which each have a maximum of 1 wagon attached to it
The next wagon that is attached to either the locomotive or another wagon, is called next
. When that value is null
, that means it's the last wagon on the train.
+-----+--+ +-----+--+ +-----+--+ +-----+------+
| L |next ---> | W-1 |next ---> | W-2 |next ---> | W-3 | null |
+-----+--+ +-----+--+ +-----+--+ +-----+------+
The box named L
is the locomotive, and W-1
- W-3
are the wagons.
In order to check all the wagons, you need to start at the locomotive!
You can find the complete train in src/data/train.js.
💡 Hint: Check out the src/index.js file to see how the functions going to be used.
It is your job to complete two functions in the src/utils/train.js:
"Walk" through the entire train, when given a starting point (the locomotive). There are three parameters:
start
: Starting point of the chain. Ideally the locomotive.actionFn
: A function that is executed for every filtered item. Use the predefineddefaultActionFn
as defaultfilterFn
: Function that filters the list, following the principles of Array filter methods. Use the predefineddefaultFilterFn
as default
Check if the lastBrakeRevision
is older than 1 year, compared to today's date.
Return true
when the brake revision is older than 1 year!
ℹ️ This is a function that can be passed as filterFn
in iterateWagons
.
Check out the contributing guide for details about how to participate.
In short:
- ✨ Create your repository by acceping the assignment using the participation link
- 🧩 Solve the puzzle
- 🐦 Add your Twitter handle to
twitter.js
- 🤖 Test your solution
- 🚀 Upload your changes to the
main
branch
In order to participate, you need to enter the following link and accept the assignment: https://classroom.github.com/a/4Bq3WTvV
Install the dependencies with
yarn install
or
npm install
Run the code with
yarn dev
or
npm run dev
This puzzle is equipped with automated tests (in the ./tests
folder). In order for your solution to qualify for winning the daily prize, all tests need to pass.
To run these tests, execute one of the following commands in your console:
yarn test
or
npm test