← 2023 questions

2023 / TIKTOK / QUESTION 15

Wellness feed

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

THE QUESTION

Sofea is a Tik Tok user. She only enjoys watching videos about wellness. These includes videos related to cooking, which she particularly enjoys, fitness and study methods. Sort the array provided below in an order where wellness videos appear at the top of her feed, with the cooking videos being prioritised at the start. Print the array with each element on a new line, numbering each element.

Starter Code:

Videos = [['painting','arts','visual'],
['curry','wellness','cooking'],
['schedule','wellness','study methods'],
['dancing','arts','musicals'],
['zumba','wellness','fitness'],
['fried rice','wellness','cooking'],
['workout','wellness','fitness'],
['acrylics','arts','visual'],
['tips','wellness','study methods'],
['cardio','wellness','fitness'],
['habits','wellness','study methods'],
['singing','arts','musicals'],
['noodles','wellness','cooking'],
['marathon','wellness','fitness']]

Output should look like this:

1. ['curry', 'wellness', 'cooking']
2. ['fried rice', 'wellness', 'cooking']
3. ['noodles', 'wellness', 'cooking']
4. ['marathon', 'wellness', 'fitness']
5. ['habits', 'wellness', 'study methods']
6. ['cardio', 'wellness', 'fitness']
7. ['tips', 'wellness', 'study methods']
8. ['workout', 'wellness', 'fitness']
9. ['zumba', 'wellness', 'fitness']
10. ['schedule', 'wellness', 'study methods']
11. ['painting', 'arts', 'visual']
12. ['dancing', 'arts', 'musicals']
13. ['acrylics', 'arts', 'visual']
14. ['singing', 'arts', 'musicals']

Question by Tze Wey. Source: Girls In Code SEA — Behind the Screens, 2023, slide 31.

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 video titles as a list or one per line. Cooking videos first, then other wellness videos, then arts. Any order within each group is accepted.

Reveal worked answer

Feed order · one valid answer

["curry", "fried rice", "noodles", "schedule", "zumba", "workout", "tips", "cardio", "habits", "marathon", "painting", "dancing", "acrylics", "singing"]

Sort by priority: wellness/cooking = 0, other wellness = 1, arts = 2. All 14 videos must appear exactly once.