One Column per Name
Return colors as a table of 0s and 1s with one column per different color, in alphabetical order: each row has a 1 in the column of its color.
Example 1
colors ["red","green","red","blue"]
returns [[0.0,0.0,1.0],[0.0,1.0,0.0],[0.0,0.0,1.0],[1.0,0.0,0.0]]
The columns are blue, green, red.
Constraints
1 <= len(colors) <= 40
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More scikit-learn problems
- Score on Unseen RowsEasy
- Small TreeEasy
- Table of Hits and MissesEasy
- Vote of the NeighborsEasy
- Yes or NoEasy
- Average Over Five FoldsMedium
- Best Number of NeighborsMedium
- Centers of the GroupsMedium