Last active
November 5, 2016 23:28
-
-
Save drkpkg/20317a92944379191f458df92f45b3a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def equilateral(a,b,c) | |
if(((a-b)+(b-c)+(a-c))==0) | |
return true | |
end | |
return false | |
end | |
def isoceles(a,b,c) | |
if(((a-b)+(b-c))==0 or ((a-b)+(a-c))==0) | |
return true | |
end | |
return false | |
end | |
def scalen(a,b,c) | |
if(a!=b and b!=c and a!=c) | |
return true | |
end | |
return false | |
end | |
counter = ARGV[0].to_i | |
starter = 0 | |
if ((counter>0) and (counter<501)) | |
counter.times do | |
a = ARGV[starter+1].to_i | |
b = ARGV[starter+2].to_i | |
c = ARGV[starter+3].to_i | |
if equilateral(a,b,c) == true | |
puts 'Equilateral' | |
end | |
if isoceles(a,b,c) == true | |
puts 'Isoceles' | |
end | |
if scalen(a,b,c) == true | |
puts 'Scalen' | |
end | |
starter += 3 | |
end | |
else | |
puts 'Error' | |
end | |
# ruby triangles.rb 3 10 10 10 12 12 11 4 2 1 | |
# Output: | |
#Equilateral | |
#Isosceles | |
#Scalene | |
# ruby triangles.rb 6000 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 | |
#Output: | |
#Error |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment