about | help | code help+videos | done | prefs |
Write a method that returns the number of complete houses that can be made from the individual parts of the array of strings. To make a house you must have one each of "floor", "wall", "roof", and "door" but they can be found in any order in the array. Once an individual part is used to make one house, that same part is used up and cannot be used to make another house. So if the array has at least 5 copies of each of the individual parts, but one of the parts has exactly 5 copies, you can make 5 houses. For example, if I have 15 "roof"s, 23 "floor"s, 17 "door"s, and 3 "wall"s, and any number of other items, I can build exactly 3 houses (because after that I have run out of walls). This is not as difficult as it seems, but will require careful thought and planning! I strongly recommend that you should not start coding until you have FIRST planned your approach on paper. For this program, you have a restricted subset of string methods you may use. You may use any combination of: .equals .substring .charAt .length but you may not use any other string methods. olympicCountHouse([""]) → 0 olympicCountHouse([]) → 0 olympicCountHouse(["roof", "wall", "door"]) → 0 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 290
Copyright Nick Parlante 2017 - privacy