Sha256: 1d9f3c1095b2410ef3c0a00e58882b2e00003d9a091adee2db2d2caeb4b45011

Contents?: true

Size: 634 Bytes

Versions: 66

Compression:

Stored size: 634 Bytes

Contents

module Triangle exposing (Triangle(..), triangleKind, version)

import Set


type Triangle
    = Equilateral
    | Isosceles
    | Scalene


version : Int
version =
    2


triangleKind : comparable -> comparable -> comparable -> 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

66 entries across 66 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.179 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.178 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.177 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.176 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.175 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.174 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.173 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.172 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.171 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.170 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.169 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.167 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.166 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.165 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.164 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.163 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.162 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.161 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.160 tracks/elm/exercises/triangle/Triangle.example.elm