Skip to content

Latest commit

 

History

History
25 lines (20 loc) · 523 Bytes

third_angle_of_a_triangle.md

File metadata and controls

25 lines (20 loc) · 523 Bytes

Description

You are given two interior angles (in degrees) of a triangle.

Write a function to return the 3rd.

Note: only positive integers will be tested.

https://en.wikipedia.org/wiki/Triangle

My Solution

def other_angle(a, b)
  180-(a+b)
end

Better/Alternative solution from Codewars

def first_non_consecutive(arr)
  arr.each_index do |i|
    return arr[i + 1] if arr[i].next != arr[i + 1]
  end
end