Sha256: 1505390796f730bcfd170de6c6c5f768313e0e5405305d0c6cf5adcdeef128e9

Contents?: true

Size: 601 Bytes

Versions: 292

Compression:

Stored size: 601 Bytes

Contents

module Triangle exposing (..)

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

292 entries across 292 versions & 1 rubygems

Version Path
trackler-2.2.1.52 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.51 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.50 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.49 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.48 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.47 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.46 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.45 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.44 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.43 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.42 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.41 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.40 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.39 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.38 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.37 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.36 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.35 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.34 tracks/elm/exercises/triangle/Triangle.example.elm
trackler-2.2.1.33 tracks/elm/exercises/triangle/Triangle.example.elm