# Find efficient seating arrangement in a line [closed]

We have X Girls and Y Boys in a class. If more girls sit together they will not behave. Similarly if more boys sit together they will not behave.

Write a program/algorithm to get maximum same gender that will be seated if seating is done to efficiently to get them behave.

Example 1: 5 girls and 1 boy Expected Output: 3 Explanation: G G B G G G

Example 2: 7 girls and 3 boys Expected Output: 2 Explanation: G G B G B G G B G G

## closed as unclear what you're asking by J42161217, AdmBorkBork, Sriotchilism O'Zaic, Robert S., JonahApr 3 at 14:44

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• Is this just ceil(max(b,g)/(1+min(b,g)))? – TFeld Apr 3 at 13:49
• Maybe this should be code-golf? – TFeld Apr 3 at 13:58
• This definitely doesn't seem complicated enough for fastest-algorithm to be all that interesting, but it could be interesting to golf. There might even be the potential for some sort of thematically appropriate semi-golf code-challenge scoring scheme, but that would probably be a bad idea. – Unrelated String Apr 4 at 9:26
• what's the winning criteria? It would probably be best to do code-golf – Jo King Apr 5 at 10:13

# Python 2, 26 bytes

lambda b,g:-min(b/~g,g/~b)


Try it online!

# JavaScript (Node.js), 31 bytes

Port of @TFeld python answer

a=>b=>-Math.min(a/~b,b/~a)+.5|0


Try it online!