dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
2.1 KiB
2.1 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 68ee9e3066cfd4eb2328e8a5 | Challenge 86: Image Search | 29 | challenge-86 |
--description--
On November 4th, 2001, Google launched its image search, allowing people to find images using search terms. In this challenge, you will imitate the image search.
Given an array of image names and a search term, return an array of image names containing the search term.
- Ignore the case when matching the search terms.
- Return the images in the same order they appear in the input array.
--hints--
image_search(["dog.png", "cat.jpg", "parrot.jpeg"], "dog") should return ["dog.png"].
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(image_search(["dog.png", "cat.jpg", "parrot.jpeg"], "dog"), ["dog.png"])`)
}})
image_search(["Sunset.jpg", "Beach.png", "sunflower.jpeg"], "sun") should return ["Sunset.jpg", "sunflower.jpeg"].
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(image_search(["Sunset.jpg", "Beach.png", "sunflower.jpeg"], "sun"), ["Sunset.jpg", "sunflower.jpeg"])`)
}})
image_search(["Moon.png", "sun.jpeg", "stars.png"], "PNG") should return ["Moon.png", "stars.png"].
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(image_search(["Moon.png", "sun.jpeg", "stars.png"], "PNG"), ["Moon.png", "stars.png"])`)
}})
image_search(["cat.jpg", "dogToy.jpeg", "kitty-cat.png", "catNip.jpeg", "franken_cat.gif"], "Cat") should return ["cat.jpg", "kitty-cat.png", "catNip.jpeg", "franken_cat.gif"].
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(image_search(["cat.jpg", "dogToy.jpeg", "kitty-cat.png", "catNip.jpeg", "franken_cat.gif"], "Cat"), ["cat.jpg", "kitty-cat.png", "catNip.jpeg", "franken_cat.gif"])`)
}})
--seed--
--seed-contents--
def image_search(images, term):
return images
--solutions--
def image_search(images, term):
lower_term = term.lower()
return [img for img in images if lower_term in img.lower()]