id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > olympicCountHouse
prev  |  next  |  chance

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)

public int olympicCountHouse(String[] str) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 290

Copyright Nick Parlante 2017 - privacy