← 2023 questions

2023 / SHOPEE / QUESTION 33

Package tracking

Try the question in your own editor, then check your output below.

THE QUESTION

Valerie has ordered a few items off shoppee. However, once she got home She got a call saying they have lost the packages! Valerie needs her new headphones as she has a DJ gig and wants to find out where her package is. All the packages ordered are stored in a 2D array in which each index stores 3 variables in the corresponding order : [Name, Current location, item]. Search through the array to find where Valeries package is located and find the corresponding postcode.

Array1 = [['Tristan', 'Hanoi', 'Book'], ['Tristan', 'Hanoi', 'HDMI'], ['Vignesh', 'Kuala Lumpur', 'Book'], ['Sofea', 'Jakarta', 'Book'], ['Finnick', 'Hanoi', 'Headphones'], ['Tristan', 'Manila', 'HDMI'], ['Charlotte', 'Manila', 'Shirt'], ['Valerie', 'Manila', 'Shirt'], ['Tristan', 'Hanoi', 'Headphones'], ['Valerie', 'Manila', 'Mouse'], ['Vignesh', 'Hanoi', 'Book'], ['Sofea', 'Taipei', 'Mama Noodles'], ['Sofea', 'Taipei', 'Mama Noodles'], ['Charlotte', 'Vientiane', 'HDMI'], ['Vignesh', 'Jakarta', 'HDMI'], ['Valerie', 'Hanoi', 'Headphones'], ['Tristan', 'Jakarta', 'Shirt'], ['Vignesh', 'Vientiane', 'Mama Noodles'], ['Vignesh', 'Kuala Lumpur', 'Book'], ['Charlotte', 'Vientiane', 'Shirt'], ['Valerie', 'Manila', 'Book'], ['Finnick', 'Manila', 'Headphones'], ['Finnick', 'Manila', 'Shirt']]
postcodes = [["Bangkok", "10110"], ["Kuala Lumpur", "43200"], ["Manila", "1000"], ["Taipei", "100019"], ["Jakarta", "10120"], ["Hanoi", "11109"], ["Vientiane", "0604"]]

Question by Ella. Source: Girls In Code SEA — Behind the Screens, 2023, slide 53.

CHECK YOUR ANSWER

Try your answer.

Run your program in your own editor, then paste its output below. This checks the stated output; it does not assess your full program. Practice attempts do not affect competition scores.

Enter the city and postcode for Valerie’s headphones.

Reveal worked answer

Location and postcode

Hanoi 11109

Match both owner Valerie and item Headphones, then look up Hanoi in the postcode table.