index | submit | rank | book

triangle – Six Triangle Types (challenge)

Every triangle can be classified as either scalene, isosceles or equilateral:

(Some authors consider equilateral to be a special case of isosceles. For the purpose of this exercise, we use Euclid’s original definition and consider isosceles triangles those with exactly two edges of the same size.)

triangle types: scalene, isosceles, equilateral, impossible

All triangles can also be classified as right, obtuse and acute:

triangle angle types: obtuse, right, acute

Write a program that given three edge sizes determines:

Input and Output

Input consists of a several lines, each with three natural numbers x, y and z where

0 < x, y, z < 10 000

For each line of input, output should contain a line indicating both classifications or impossible.

Example input

3 4 5
3 3 1
6 4 3
1 1 1
7 2 3

Example output

scalene right
isosceles acute
scalene obtuse
equilateral acute
impossible

Scoring

Hints

If are having trouble to get a full score in this exercise, try to come up with other test cases besides the ones given on the example inputs. Does your program still produce the expected results on them? What if you change the order in which the sides are given?

try first: triangle1

try next: calc

index | submit | rank | book

Copyright © 2020-2022 Rudy Matela
This text is available under the CC BY-SA 4.0 license.
Originally available on cscx.org/triangle