Sha256: 118407838d25c471d6d307777a3853b8e64c09fee6a71bf8926d3bf5044851d0

Contents?: true

Size: 347 Bytes

Versions: 325

Compression:

Stored size: 347 Bytes

Contents

module Hamming exposing (..)

import String exposing (length, toList)


distance : String -> String -> Maybe Int
distance left right =
    if length left /= length right then
        Nothing
    else
        List.map2 (\l r -> l /= r) (toList left) (toList right)
            |> List.filter identity
            |> List.length
            |> Just

Version data entries

325 entries across 325 versions & 1 rubygems

Version Path
trackler-1.0.1.2 tracks/elm/exercises/hamming/Hamming.example
trackler-1.0.1.1 tracks/elm/exercises/hamming/Hamming.example
trackler-1.0.1.0 tracks/elm/exercises/hamming/Hamming.example
trackler-1.0.0.1 tracks/elm/exercises/hamming/Hamming.example
trackler-1.0.0 tracks/elm/exercises/hamming/Hamming.example