Activity 15: Create Your Own AI Guide!¶
The instructions are provide in the worksheet:
Supplemental Material¶
Part 1: wordMultiple¶
The following problem text is taken from the CodingBat: wordMultiple exercise.
wordMultiple
Given an array of strings, return a Map
wordMultiple(["a", "b", "a", "c", "b"]) → {"a": true, "b": true, "c": false}
wordMultiple(["c", "b", "a"]) → {"a": false, "b": false, "c": false}
Part 2: wordMultiplePositions¶
Here is a slightly more difficult variation on the previous problem:
wordMultiplePositions
Given an array of strings, return a Map
wordMultiplePositions(["a", "b", "a", "c", "b"]) → {"a": [0, 2], "b": [1, 4]}
wordMultiplePositions(["c", "b", "a"]) → {}
wordMultiplePositions(["c", "c", "c", "c"]) → {"c": [0, 1, 2, 3]}
An online IDE is provided for you to test your code: OneCompiler: wordMultiplePositions.