Skip to content

Instantly share code, notes, and snippets.

@vuorejo1
Created June 25, 2013 14:24
Show Gist options
  • Save vuorejo1/5858852 to your computer and use it in GitHub Desktop.
Save vuorejo1/5858852 to your computer and use it in GitHub Desktop.
def triangle(a, b, c)
kolmio = Array.new
kolmio = [a, b, c]
if kolmio.size.uniq == 1 then
return :equilateral
elsif kolmio.uniq.size == 2 then
return :isosceles
elsif kolmio.uniq.size == 3 then
return :scalene
end
end
@judofyr
Copy link

judofyr commented Jun 25, 2013

def triangle(a, b, c)
  case [a, b, c].uniq.size
  when 1
    :equilateral
  when 2
    :isosceles
  when 3
    :scalene
  end
end

@leejarvis
Copy link

def triangle(*args)
  case args.uniq.size
  when 1; :equilateral
  when 2; :isoceles
  when 3; :scalene
  end
end

@leejarvis
Copy link

def triangle(*args)
  [:equilateral, :isoceles, :scalene](args.uniq.size-1]
end

/runs away

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment