Given the measures of two of the interior angles of a triangle (x and y; the other angle can be easily calculated with 180 - x - y), draw a line segment that cuts this triangle into two isosceles triangles. You need to output the angle measures of both of your triangles.

However, because the base angles are the same, you only need to output the list [apex angle, base angle] of the divided triangles for both of the isosceles triangles. You can output the divided triangles in any order.

An example

Say your input is 100, 60.

Let's take a look at the complete triangle first. The triangle looks approximately like this.


60            20

Now we try to divide one of the angles such that two divided triangles are both isosceles triangles.


(40,20)           20

Now our bottom triangle is an isosceles triangle, since both of the base angles
of the bottom triangle are 20. The angle measures of the bottom triangle
looks approximately like this.

20             20

Now, is the top triangle an isosceles triangle?


It is an isosceles triangle, because two of the angle measures are 40.

Therefore, for [100, 60], you need to output [[100, 40], [140, 20]].

Example cases

[20, 40] -> [[140, 20], [100, 40]]
[45, 45] -> [[90, 45], [90, 45]]
[36, 72] -> [[108, 36], [36, 72]]
[108, 36] -> [[108, 36], [36, 72]]
[44, 132] -> [[92, 44], [4, 88]]


  • You can always assume that the triangle is dividable into two isosceles triangles.
  • You can output one of the many solutions of the cases; for example, you can also output [20, 40] -> [[100, 40], [20, 80]] for the first test case.
  • 3
    \$\begingroup\$ Nice challenge, but I think it could benefit a lot from some (rough) pictures to illustrate the example better. It took me a while to figure out what was being asked tbh. \$\endgroup\$ – Kevin Cruijssen Jul 1 at 14:59
  • 5
    \$\begingroup\$ Is it guaranteed that the input triangle can be divided that way? (For instance, it's impossible to divide an equilateral triangle into 2 isosceles triangles.) \$\endgroup\$ – Arnauld Jul 1 at 16:00
  • 1
    \$\begingroup\$ Did you mean [20, 40] -> [[140, 20], [100, 40]] for the first test case? \$\endgroup\$ – Noodle9 Jul 1 at 16:29
  • 1
    \$\begingroup\$ The 3rd test case should be [36, 72] -> [108, 36], [36, 72] \$\endgroup\$ – Surculose Sputum Jul 1 at 17:07
  • 1
    \$\begingroup\$ FYI I found a PDF linked from a Math Overflow question. A triangle can be divided into 2 isosceles triangles either if the smallest angle is < 45° and is exactly one half or one third of one of the other angles, or if one of the angles is 90°. \$\endgroup\$ – Neil Jul 1 at 19:10

05AB1E, 39 38 bytes


Input as a pair of integers; output as a pair of pairs of integers.

Try it online or verify all test cases.


O                 # Take the sum of the (implicit) input-pair of angles
 ƵΔα              # Get the absolute difference with (compressed) 180
    ª             # Append that third angle to the (implicit) input-pair
     ©            # Store it in variable `®` (without popping)
90K               # Remove 90 from the triplet of angles
   D              # Duplicate it
®Qi               # If it's still equal to `®` (thus none were 90):
   ʒ              #  Filter the triplet by:
    45‹           #   Check that the angle is smaller than 45
               *  #   AND
        y2 S*     #   Check if the angle multiplied by 2
          3S* à   #   or multiplied by 3
       ®     å    #   is in the triplet of angles `®`
   }ß             #  After the filter: pop and push the minimum of the remaining angles
     x            #  Double it (without popping)
      ‚           #  Pair the non-doubled and doubled values together
  }ε              # After the if statement: map the angles in the pair to:
    90α           #  Get the absolute difference with 90
       ·          #  Double it
        y‚        #  And pair it with the non-mapped angle
                  # (after which the resulting pair of pairs is output implicitly)

See this 05AB1E tip of mine (section How to compress large integers?) to understand why ƵΔ is 180.

| improve this answer | |

Python 3.8 (pre-release), 123 129 bytes

g=lambda*p:[[180-2*x,x]for x in p]
f=lambda a,b:((c:=180-a-b)==90or c>45>2in{a/b,b/a})*g(a,b)or(c/3in{a,b})*g(c/3,c/3*2)or f(b,c)

Try it online!

A function that takes in 2 angles, and returns the 2 isosceles triangles. If the given triangle cannot be divided, the function loops forever.

| improve this answer | |

APL (Dyalog Unicode), 47 bytes

(⊢,⍨¨2×90-⊢)∘{90∊⍵:⍵~90⋄1 2×⌊/⍵∩∊⍵÷⊂2 3},,180-+

Try it online!

A tacit function that takes two angles as left and right arguments.

Uses the information found by Neil, modified to take care of xnor's test case:

A triangle can be divided into 2 isosceles triangles either if one of the angles is < 45° and is exactly one half or one third of one of the other angles, or if one of the angles is 90°.

Now, the base angles of the result can be found as follows:

  • If one of the angles is 90°, the bases are the other two angles.
  • Otherwise, one of the angles is < 45° and is exactly one half or one third of one of the other angles should hold, because the input is guaranteed to have a solution. In this case, the angle satisfying the condition becomes the base for one triangle, and the other triangle's base angle is twice the angle.

How it works: the code

(⊢,⍨¨2×90-⊢)∘{90∊⍵:⍵~90⋄1 2×⌊/⍵∩∊⍵÷⊂2 3},,180-+  ⍝ Left, Right: two angles
                                        ,,180-+  ⍝ Length-3 vector of three angles
             {                         }  ⍝ Find two base angles:
              90∊⍵:⍵~90⋄                  ⍝ If an angle is 90, the bases are the other two
                              ⍵∩∊⍵÷⊂2 3   ⍝ Otherwise, find the angles that are 1÷2 or 1÷3 of another
                        1 2×⌊/            ⍝ Take the minimum angle of that and attach its double
(          )∘  ⍝ Attach apex angles to two base angles
     2×90-⊢    ⍝ apex=180-2×base
 ⊢,⍨¨          ⍝ Attach each apex to the left of the base
| improve this answer | |

Charcoal, 66 bytes


Try it online! Link is to verbose version of code. Explanation:


Input the two provided angles.


Calculate the third angle.


See if any angle under 45° appears doubled or tripled.


If so then the base angles of the result are that angle and the doubled angle.


Otherwise if this is a right-angled triangle, ...


... then the base angles of the result are the other two angles.


If we got any base angles then compute the apex angles and output all of the angles.

| improve this answer | |

R, 146 132 128 bytes

or 158 150 146 bytes to output the 4 angles as 2 lists of 2 angles each.


Try it online!

An approach that does not use the 'one-half or one-third' trick:

Consider initial triangle with angles a,b,s, where s is the smallest angle (so s is never divided). a will be the angle that gets divided.

case 1: right-angle triangle (uses both bases of smaller triangles as sides) => divide right angle

case 2: starting triangle uses base and base+wall of smaller triangles as sides

=> t1=b,b,d (where d is formed from divided angle: d=a-s)

=> t2=s,s,180-b

=> so (from t2) we get b=2*s and we can specify both t1 and t2 from s

case 3: starting triangle uses only 1 base as side (other is created internally)

=> t1=b,b,180-d (where d is formed from divided angle: d=a-b)

=> t2=s,d,d

=> so (from t2): d=90-s/2, and we can specify both t1 and t2 from s

and (from t1): b=45-s/4 to check when this case is satisfied (but we won't bother to do this...)

Readable code:

cuttri=function(i,j,t=c(i,j,180-i-j)){      # we don't know which angle is a or b
    s=min(t)                                # but we know s is the smallest
    if(90 %in% t){                          # case 1: right-angle triangle
    else if((2*s) %in% t){                  # case 2:
    else if((45-s/4) %in% t){               # case 3 (but we don't actually need to check if
     list(c(45-s/4,90+s/2),c(s,90-s/2))}    # we're assured that triangle can be divided)

Note that because the golfed code skips the final check for case 3, the output will be incorrect if it is 'fed' non-valid angles corresponding to a triangle that can't be divided into two isosceles triangles.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy