-1
\$\begingroup\$

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

\$\endgroup\$

closed as unclear what you're asking by J42161217, AdmBorkBork, Sriotchilism O'Zaic, Robert S., Jonah Apr 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.

  • 1
    \$\begingroup\$ Is this just ceil(max(b,g)/(1+min(b,g)))? \$\endgroup\$ – TFeld Apr 3 at 13:49
  • 2
    \$\begingroup\$ Maybe this should be code-golf? \$\endgroup\$ – TFeld Apr 3 at 13:58
  • 2
    \$\begingroup\$ 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. \$\endgroup\$ – Unrelated String Apr 4 at 9:26
  • \$\begingroup\$ what's the winning criteria? It would probably be best to do code-golf \$\endgroup\$ – Jo King Apr 5 at 10:13
4
\$\begingroup\$

Python 2, 26 bytes

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

Try it online!

\$\endgroup\$
1
\$\begingroup\$

JavaScript (Node.js), 31 bytes

Port of @TFeld python answer

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

Try it online!

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.