Sha256: 1b39a41e99f11f3abd04a618f3ad73790e6ac62ff961198ffc45cbfbc1e163eb

Contents?: true

Size: 589 Bytes

Versions: 38

Compression:

Stored size: 589 Bytes

Contents

module Triangle exposing (..)

import Set


type Triangle
    = Equilateral
    | Isosceles
    | Scalene


version : Int
version =
    2


triangleKind : number -> number -> number -> Result String Triangle
triangleKind x y z =
    if x <= 0 || y <= 0 || z <= 0 then
        Err "Invalid lengths"
    else if x + y <= z || x + z <= y || y + z <= x then
        Err "Violates inequality"
    else
        case Set.size (Set.fromList [ x, y, z ]) of
            1 ->
                Ok Equilateral

            2 ->
                Ok Isosceles

            _ ->
                Ok Scalene

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
trackler-2.0.5.1 tracks/elm/exercises/triangle/Triangle.example
trackler-2.0.5.0 tracks/elm/exercises/triangle/Triangle.example
trackler-2.0.4.0 tracks/elm/exercises/triangle/Triangle.example
trackler-2.0.3.9 tracks/elm/exercises/triangle/Triangle.example
trackler-2.0.3.8 tracks/elm/exercises/triangle/Triangle.example
trackler-2.0.3.7 tracks/elm/exercises/triangle/Triangle.example
trackler-2.0.3.6 tracks/elm/exercises/triangle/Triangle.example
trackler-2.0.3.5 tracks/elm/exercises/triangle/Triangle.example
trackler-2.0.3.4 tracks/elm/exercises/triangle/Triangle.example
trackler-2.0.3.3 tracks/elm/exercises/triangle/Triangle.example
trackler-2.0.3.2 tracks/elm/exercises/triangle/Triangle.example
trackler-2.0.3.1 tracks/elm/exercises/triangle/Triangle.example
trackler-2.0.3.0 tracks/elm/exercises/triangle/Triangle.example
trackler-2.0.2.0 tracks/elm/exercises/triangle/Triangle.example
trackler-2.0.1.2 tracks/elm/exercises/triangle/Triangle.example
trackler-2.0.1.1 tracks/elm/exercises/triangle/Triangle.example
trackler-2.0.1.0 tracks/elm/exercises/triangle/Triangle.example
trackler-2.0.0.10 tracks/elm/exercises/triangle/Triangle.example
trackler-2.0.0.9 tracks/elm/exercises/triangle/Triangle.example
trackler-2.0.0.8 tracks/elm/exercises/triangle/Triangle.example