TITLE: Make isosceles triangle with matchsticks
QUESTION [1 upvotes]: Alan is using matchsticks to make isosceles triangles. Isosceles triangles have at least two sides of the same length. How many different single isosceles triangles can he make with B matchsticks, using all the matchsticks each time? 

Not sure I understand the answer here where $B = 45$ (or 33?):
Why do we have $X+2X=B$? What if B is not divisible by 3?
What I tried:
If it's 3,5,6, Alan can make only 1 isosceles triangle. If it's 7, he can make 2.
Is this something like $\lfloor \frac{x}{3} \rfloor$? Or  $\lfloor \frac{x}{3}+1 \rfloor - 1$?

REPLY [1 votes]: Well, if we call the number of matches in the base side of the triangle $a$, and the number of matches in the other two sides (which totals to $2b$ for both sides) then we need to find the number of solutions to $a+2b=B$. This is simply the number of numbers you can fill in for $b$, since then $a=B-2b$ follows.
Thus, in general, the number of triangles you can make is $\lfloor\tfrac 12(B-1)\rfloor$, because that's how many $b$'s there are such that $B-2b\geq1$.
As correctly noted, we need to take the triangle inequality $2b>a$ into account. When we try to find the number of $b$'s that do not satisfy that property, we look at $2b\leq a$, or $2b\leq B-2b$, in other words, all $b$ less than or equal to $\frac{B}{4}$. Subtract this from $\lfloor\tfrac 12(B-1)\rfloor$ to find the final answer:
$$\lfloor\tfrac 12(B-1)\rfloor-\lfloor\frac{B}{4}\rfloor$$

Note that now for $B=45$, we get the correct answer $$\lfloor\tfrac 12(45-1)\rfloor-\lfloor\frac{45}{4}\rfloor=\lfloor22\rfloor - 11=11$$
{"set_name": "stack_exchange", "score": 1, "question_id": 2174942}