Retired
Filter Map Sort Practice (retired)
82oa998
Description:
Given a list of Item instances, keep only the items that have a color of "Red" that are LESS than 7 days old.
Once you have the matching items, return the items sorted by Category name (alphabetically, ascending).
class Item {
String name;
String color;
Instant created;
Integer categoryID;
Category category; // will be null until you set it
}
enum Category {
HAZARDOUS, OVERSIZED, FRAGILE, OBLONG, HEAVY
}
Example Input:
// Today is: 2021-07-27T01:32:07.199Z
[
{
id: "a1",
color: "Red",
created: "2021-07-26T01:32:07.199Z",
categoryID: 3
},
{
id: "a2",
color: "Green",
created: "2021-07-23T01:32:07.199Z",
categoryID: 1
},
{
id: "a3",
color: "Red",
created: "2021-07-25T01:32:07.199Z",
categoryID: 1
},
{
id: "a4",
color: "Red",
created: "2021-07-25T01:32:07.199Z",
categoryID: 2
}
]
Expected Output:
[
{
id: "a4",
color: "Red",
created: "2021-07-01T01:32:07.199Z",
categoryID: 2 // FRAGILE
},
{
id: "a1",
color: "Red",
created: "2021-06-27T01:32:07.199Z",
categoryID: 3 // OBLONG
},
{
id: "a3",
color: "Red",
created: "2021-04-27T01:32:07.199Z",
categoryID: 1 // OVERSIZED
},
]
Fundamentals
Filtering
Sorting
Similar Kata:
Stats:
Created | Jul 27, 2021 |
Warriors Trained | 84 |
Total Skips | 2 |
Total Code Submissions | 1289 |
Total Times Completed | 82 |
Java Completions | 82 |
Total Stars | 4 |
% of votes with a positive feedback rating | 50% of 7 |
Total "Very Satisfied" Votes | 3 |
Total "Somewhat Satisfied" Votes | 1 |
Total "Not Satisfied" Votes | 3 |
Total Rank Assessments | 7 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |