Daily Challenge #6 - Grandma and her friends
dev.to staff
Posted on July 3, 2019
Another day, another challenge. Today, your task is to help your grandmother visit her friends.
This challenge comes from user @g964 on CodeWars:
Your granny, who lives in town X0, has friends. These friends are given in an array, for example: array of friends is
[ "A1", "A2", "A3", "A4", "A5" ].
Note: the order of friends is this array and it must not be changed since this order gives the order in which they will be visited.
These friends inhabit towns and you have an array with friends and towns, for example:
[ ["A1", "X1"], ["A2", "X2"], ["A3", "X3"], ["A4", "X4"] ]
or
[ ("A1", "X1"), ("A2", "X2"), ("A3", "X3"), ("A4", "X4") ]
or
(C)
{"A1", "X1", "A2", "X2", "A3", "X3", "A4", "X4"}which means A1 is in town X1, A2 in town X2... It can happen that we don't know the town of one of the friends.
Your granny wants to visit her friends and to know how many miles she will have to travel. Can you help her figure it out?
Thank you to CodeWars, who has licensed redistribution of this challenge under the 2-Clause BSD License!
Want to propose a challenge for a future post? Email yo+challenge@dev.to with your suggestions!
Posted on July 3, 2019
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.