Merge pull request #31 from tgecho/exercises

A big pile of exercises
This commit is contained in:
Lew Parker 2016-03-14 07:14:24 -06:00
commit a082e0ffd9
38 changed files with 917 additions and 2 deletions

View file

@ -7,7 +7,16 @@
"problems": [
"hello-world",
"leap",
"bob"
"pangram",
"rna-transcription",
"hamming",
"word-count",
"bob",
"run-length-encoding",
"difference-of-squares",
"anagram",
"raindrops",
"triangle"
],
"deprecated": [

View file

@ -7,7 +7,16 @@
".",
"./exercises/hello-world",
"./exercises/leap",
"./exercises/bob"
"./exercises/pangram",
"./exercises/rna-transcription",
"./exercises/hamming",
"./exercises/word-count",
"./exercises/bob",
"./exercises/run-length-encoding",
"./exercises/difference-of-squares",
"./exercises/anagram",
"./exercises/raindrops",
"./exercises/triangle"
],
"exposed-modules": [],
"dependencies": {

View file

@ -0,0 +1 @@
module Anagram (..) where

View file

@ -0,0 +1,17 @@
module Anagram (..) where
import String exposing (toLower, toList)
detect : String -> List String -> List String
detect word candidates =
let
original = toLower word
ref = normalize word
in
List.filter (\w -> normalize w == ref && toLower w /= original) candidates
normalize : String -> List Char
normalize word =
word |> toLower |> toList |> List.sort

View file

@ -0,0 +1,138 @@
module Main (..) where
import Task
import Console
import ElmTest exposing (..)
import Anagram exposing (detect)
tests : Test
tests =
suite
"Anagram"
[ test
"no matches"
(assertEqual
[]
(detect "diaper" [ "hello", "world", "zombies", "pants" ])
)
, test
"detects simple anagram"
(assertEqual
[ "tan" ]
(detect "ant" [ "tan", "stand", "at" ])
)
, test
"does not detect false positives"
(assertEqual
[]
(detect "galea" [ "eagle" ])
)
, test
"detects multiple anagrams"
(assertEqual
[ "stream", "maters" ]
(detect "master" [ "stream", "pigeon", "maters" ])
)
, test
"does not detect anagram subsets"
(assertEqual
[]
(detect "good" [ "dog", "goody" ])
)
, test
"detects anagram"
(assertEqual
[ "inlets" ]
(detect "listen" [ "enlists", "google", "inlets", "banana" ])
)
, test
"detects multiple anagrams"
(assertEqual
[ "gallery", "regally", "largely" ]
(detect "allergy" [ "gallery", "ballerina", "regally", "clergy", "largely", "leading" ])
)
, test
"does not detect indentical words"
(assertEqual
[ "cron" ]
(detect "corn" [ "corn", "dark", "Corn", "rank", "CORN", "cron", "park" ])
)
, test
"does not detect non-anagrams with identical checksum"
(assertEqual
[]
(detect "mass" [ "last" ])
)
, test
"detects anagrams case-insensitively"
(assertEqual
[ "Carthorse" ]
(detect "Orchestra" [ "cashregister", "Carthorse", "radishes" ])
)
, test
"detects anagrams using case-insensitive subject"
(assertEqual
[ "carthorse" ]
(detect "Orchestra" [ "cashregister", "carthorse", "radishes" ])
)
, test
"detects anagrams using case-insensitve possible matches"
(assertEqual
[ "Carthorse" ]
(detect "orchestra" [ "cashregister", "Carthorse", "radishes" ])
)
, test
"does not detect a word as its own anagram"
(assertEqual
[]
(detect "banana" [ "Banana" ])
)
, test
"does not detect a anagram if the original word is repeated"
(assertEqual
[]
(detect "go" [ "go Go GO" ])
)
, test
"anagrams must use all letters exactly once"
(assertEqual
[]
(detect "tapper" [ "patter" ])
)
, test
"eliminates anagrams with the same checksum"
(assertEqual
[]
(detect "mass" [ "last" ])
)
, test
"detects unicode anagrams"
(assertEqual
[ "ΒΓΑ", "γβα" ]
(detect "ΑΒΓ" [ "ΒΓΑ", "ΒΓΔ", "γβα" ])
)
, test
"eliminates misleading unicode anagrams"
(assertEqual
[]
(detect "ΑΒΓ" [ "ABΓ" ])
)
, test
"capital word is not own anagram"
(assertEqual
[]
(detect "BANANA" [ "Banana" ])
)
, test
"anagrams must use all letters exactly once"
(assertEqual
[]
(detect "patter" [ "tapper" ])
)
]
port runner : Signal (Task.Task x ())
port runner =
Console.run (consoleRunner tests)

View file

@ -0,0 +1,16 @@
{
"version": "1.0.0",
"summary": "Exercism problems in Elm.",
"repository": "https://github.com/exercism/xelm.git",
"license": "BSD3",
"source-directories": [
"."
],
"exposed-modules": [],
"dependencies": {
"deadfoxygrandpa/elm-test": "3.0.1 <= v < 4.0.0",
"elm-lang/core": "2.0.0 <= v < 4.0.0",
"laszlopandy/elm-console": "1.1.0 <= v < 2.0.0"
},
"elm-version": "0.15.0 <= v < 0.17.0"
}

View file

@ -0,0 +1 @@
module DifferenceOfSquares (..) where

View file

@ -0,0 +1,19 @@
module DifferenceOfSquares (..) where
squareOfSum : Int -> Int
squareOfSum n =
let
sum = n * (n + 1) // 2
in
sum * sum
sumOfSquares : Int -> Int
sumOfSquares n =
List.sum (List.map (\m -> m * m) [0..n])
difference : Int -> Int
difference n =
squareOfSum n - sumOfSquares n

View file

@ -0,0 +1,37 @@
module Main (..) where
import Task
import Console
import ElmTest exposing (..)
import DifferenceOfSquares exposing (squareOfSum, sumOfSquares, difference)
tests : Test
tests =
suite
"DifferenceOfSquares"
[ suite
"square the sum of the numbers up to the given number"
[ test "square of sum 5" (assertEqual 225 (squareOfSum 5))
, test "square of sum 10" (assertEqual 3025 (squareOfSum 10))
, test "square of sum 100" (assertEqual 25502500 (squareOfSum 100))
]
, suite
"sum the squares of the numbers up to the given number"
[ test "sum of squares 5" (assertEqual 55 (sumOfSquares 5))
, test "sum of squares 10" (assertEqual 385 (sumOfSquares 10))
, test "sum of squares 100" (assertEqual 338350 (sumOfSquares 100))
]
, suite
"subtract sum of squares from square of sums"
[ test "difference of squares 0" (assertEqual 0 (difference 0))
, test "difference of squares 5" (assertEqual 170 (difference 5))
, test "difference of squares 10" (assertEqual 2640 (difference 10))
, test "difference of squares 100" (assertEqual 25164150 (difference 100))
]
]
port runner : Signal (Task.Task x ())
port runner =
Console.run (consoleRunner tests)

View file

@ -0,0 +1,16 @@
{
"version": "1.0.0",
"summary": "Exercism problems in Elm.",
"repository": "https://github.com/exercism/xelm.git",
"license": "BSD3",
"source-directories": [
"."
],
"exposed-modules": [],
"dependencies": {
"deadfoxygrandpa/elm-test": "3.0.1 <= v < 4.0.0",
"elm-lang/core": "2.0.0 <= v < 4.0.0",
"laszlopandy/elm-console": "1.1.0 <= v < 2.0.0"
},
"elm-version": "0.15.0 <= v < 0.17.0"
}

View file

@ -0,0 +1 @@
module Hamming (..) where

View file

@ -0,0 +1,14 @@
module Hamming (..) where
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

View file

@ -0,0 +1,60 @@
module Main (..) where
import Task
import Console
import ElmTest exposing (..)
import Hamming exposing (distance)
tests : Test
tests =
suite
"Hamming"
[ test
"identical strands"
(assertEqual (distance "A" "A") (Just 0))
, test
"long identical strands"
(assertEqual (distance "GGACTGA" "GGACTGA") (Just 0))
, test
"complete distance in single nucleotide strands"
(assertEqual (distance "A" "G") (Just 1))
, test
"complete distance in small strands"
(assertEqual (distance "AG" "CT") (Just 2))
, test
"small distance in small strands"
(assertEqual (distance "AT" "CT") (Just 1))
, test
"small distance"
(assertEqual (distance "GGACG" "GGTCG") (Just 1))
, test
"small distance in long strands"
(assertEqual (distance "ACCAGGG" "ACTATGG") (Just 2))
, test
"non-unique character in first strand"
(assertEqual (distance "AGA" "AGG") (Just 1))
, test
"non-unique character in second strand"
(assertEqual (distance "AGG" "AGA") (Just 1))
, test
"large distance"
(assertEqual (distance "GATACA" "GCATAA") (Just 4))
, test
"large distance in off-by-one strand"
(assertEqual (distance "GGACGGATTCTG" "AGGACGGATTCT") (Just 9))
, test
"empty strands"
(assertEqual (distance "" "") (Just 0))
, test
"disallow first strand longer"
(assertEqual (distance "AATG" "AAA") Nothing)
, test
"disallow second strand longer"
(assertEqual (distance "ATA" "AGTG") Nothing)
]
port runner : Signal (Task.Task x ())
port runner =
Console.run (consoleRunner tests)

View file

@ -0,0 +1,16 @@
{
"version": "1.0.0",
"summary": "Exercism problems in Elm.",
"repository": "https://github.com/exercism/xelm.git",
"license": "BSD3",
"source-directories": [
"."
],
"exposed-modules": [],
"dependencies": {
"deadfoxygrandpa/elm-test": "3.0.1 <= v < 4.0.0",
"elm-lang/core": "2.0.0 <= v < 4.0.0",
"laszlopandy/elm-console": "1.1.0 <= v < 2.0.0"
},
"elm-version": "0.15.0 <= v < 0.17.0"
}

View file

@ -0,0 +1 @@
module Pangram where

View file

@ -0,0 +1,17 @@
module Pangram (..) where
import String exposing (toLower, contains, fromChar)
isPangram : String -> Bool
isPangram sentence =
let
normalized =
toLower sentence
in
String.all (\c -> contains (fromChar c) normalized) alphabet
alphabet : String
alphabet =
"abcdefghijklmnopqrstuvwxyz"

View file

@ -0,0 +1,48 @@
module Main (..) where
import Task
import Console
import ElmTest exposing (..)
import Pangram exposing (isPangram)
tests : Test
tests =
suite
"Pangram"
[ test
"sentence empty"
(assertEqual
False
(isPangram "")
)
, test
"pangram with only lower case"
(assertEqual
True
(isPangram "the quick brown fox jumps over the lazy dog")
)
, test
"missing character 'x'"
(assertEqual
False
(isPangram "a quick movement of the enemy will jeopardize five gunboats")
)
, test
"pangram with mixed case and punctuation"
(assertEqual
True
(isPangram "\"Five quacking Zephyrs jolt my wax bed.\"")
)
, test
"pangram with non ascii characters"
(assertEqual
True
(isPangram "Victor jagt zwölf Boxkämpfer quer über den großen Sylter Deich.")
)
]
port runner : Signal (Task.Task x ())
port runner =
Console.run (consoleRunner tests)

View file

@ -0,0 +1,16 @@
{
"version": "1.0.0",
"summary": "Exercism problems in Elm.",
"repository": "https://github.com/exercism/xelm.git",
"license": "BSD3",
"source-directories": [
"."
],
"exposed-modules": [],
"dependencies": {
"deadfoxygrandpa/elm-test": "3.0.1 <= v < 4.0.0",
"elm-lang/core": "2.0.0 <= v < 4.0.0",
"laszlopandy/elm-console": "1.1.0 <= v < 2.0.0"
},
"elm-version": "0.15.0 <= v < 0.17.0"
}

View file

@ -0,0 +1 @@
module Raindrops (..) where

View file

@ -0,0 +1,20 @@
module Raindrops where
import String
raindrops : Int -> String
raindrops number =
let
drops =
[ if number % 3 == 0 then "Pling" else ""
, if number % 5 == 0 then "Plang" else ""
, if number % 7 == 0 then "Plong" else ""
]
result =
String.join "" drops
in
if result == "" then
toString number
else
result

View file

@ -0,0 +1,33 @@
module Main (..) where
import Task
import Console
import ElmTest exposing (..)
import Raindrops exposing (raindrops)
tests : Test
tests =
suite
"Raindrops"
[ test "1" (assertEqual "1" (raindrops 1))
, test "3" (assertEqual "Pling" (raindrops 3))
, test "5" (assertEqual "Plang" (raindrops 5))
, test "7" (assertEqual "Plong" (raindrops 7))
, test "6" (assertEqual "Pling" (raindrops 6))
, test "9" (assertEqual "Pling" (raindrops 9))
, test "10" (assertEqual "Plang" (raindrops 10))
, test "14" (assertEqual "Plong" (raindrops 14))
, test "15" (assertEqual "PlingPlang" (raindrops 15))
, test "21" (assertEqual "PlingPlong" (raindrops 21))
, test "25" (assertEqual "Plang" (raindrops 25))
, test "35" (assertEqual "PlangPlong" (raindrops 35))
, test "49" (assertEqual "Plong" (raindrops 49))
, test "52" (assertEqual "52" (raindrops 52))
, test "105" (assertEqual "PlingPlangPlong" (raindrops 105))
]
port runner : Signal (Task.Task x ())
port runner =
Console.run (consoleRunner tests)

View file

@ -0,0 +1,16 @@
{
"version": "1.0.0",
"summary": "Exercism problems in Elm.",
"repository": "https://github.com/exercism/xelm.git",
"license": "BSD3",
"source-directories": [
"."
],
"exposed-modules": [],
"dependencies": {
"deadfoxygrandpa/elm-test": "3.0.1 <= v < 4.0.0",
"elm-lang/core": "2.0.0 <= v < 4.0.0",
"laszlopandy/elm-console": "1.1.0 <= v < 2.0.0"
},
"elm-version": "0.15.0 <= v < 0.17.0"
}

View file

@ -0,0 +1 @@
module RNATranscription (..) where

View file

@ -0,0 +1,28 @@
module RNATranscription (toRNA) where
import String
toRNA : String -> Result Char String
toRNA dna =
dna
|> String.toList
|> List.map toRNANucleotide
|> resultExtraCombine
|> Result.map (List.map String.fromChar)
|> Result.map (String.join "")
-- Copied from elm-result-extra
resultExtraCombine : List (Result x a) -> Result x (List a)
resultExtraCombine = List.foldr (Result.map2 (::)) (Ok [])
toRNANucleotide : Char -> Result Char Char
toRNANucleotide nuc =
case nuc of
'C' -> Ok 'G'
'G' -> Ok 'C'
'A' -> Ok 'U'
'T' -> Ok 'A'
_ -> Err nuc

View file

@ -0,0 +1,39 @@
module Main (..) where
import Task
import Console
import ElmTest exposing (..)
import RNATranscription exposing (toRNA)
tests : Test
tests =
suite
"RNATranscription"
[ test
"complement of cytosine is guanine"
(assertEqual (Ok "G") (toRNA "C"))
, test
"complement of guanine is cytosine"
(assertEqual (Ok "C") (toRNA "G"))
, test
"complement of thymine is adenine"
(assertEqual (Ok "A") (toRNA "T"))
, test
"complement of adenine is uracil"
(assertEqual (Ok "U") (toRNA "A"))
, test
"complement"
(assertEqual (Ok "UGCACCAGAAUU") (toRNA "ACGTGGTCTTAA"))
, test
"correctly handles completely invalid input"
(assertEqual (Err 'X') (toRNA "XXX"))
, test
"correctly handles partially invalid input"
(assertEqual (Err 'U') (toRNA "UGAAXXXGACAUG"))
]
port runner : Signal (Task.Task x ())
port runner =
Console.run (consoleRunner tests)

View file

@ -0,0 +1,16 @@
{
"version": "1.0.0",
"summary": "Exercism problems in Elm.",
"repository": "https://github.com/exercism/xelm.git",
"license": "BSD3",
"source-directories": [
"."
],
"exposed-modules": [],
"dependencies": {
"deadfoxygrandpa/elm-test": "3.0.1 <= v < 4.0.0",
"elm-lang/core": "2.0.0 <= v < 4.0.0",
"laszlopandy/elm-console": "1.1.0 <= v < 2.0.0"
},
"elm-version": "0.15.0 <= v < 0.17.0"
}

View file

@ -0,0 +1 @@
module RunLengthEncoding (..) where

View file

@ -0,0 +1,63 @@
module RunLengthEncoding (encode, decode) where
import String exposing (fromChar)
import List exposing (head, tail)
import Maybe exposing (withDefault)
import Regex
{-
To the unaware: this was written by a very green elmer, so don't consider
it an idiomatic exemplar to emulate.
-}
encode : String -> String
encode string =
String.toList string
|> List.foldr countChars []
|> List.map stringifyCounts
|> String.join ""
countChars : a -> List ( number, a ) -> List ( number, a )
countChars current counted =
case head counted of
Just ( count, previous ) ->
if previous == current then
( count + 1, current ) :: withDefault [] (tail counted)
else
( 1, current ) :: counted
Nothing ->
[ ( 1, current ) ]
stringifyCounts : ( number, Char ) -> String
stringifyCounts ( count, char ) =
if count > 1 then
toString count ++ fromChar char
else
fromChar char
decode : String -> String
decode string =
string
|> Regex.find Regex.All (Regex.regex "(\\d+)|(\\D)")
|> List.map .match
|> List.foldl expandCounts ( "", Nothing )
|> fst
expandCounts : String -> ( String, Maybe Int ) -> ( String, Maybe Int )
expandCounts match ( result, count ) =
case count of
Just number ->
( result ++ String.repeat number match, Nothing )
Nothing ->
case String.toInt match of
Ok number ->
( result, Just number )
Err _ ->
( result ++ match, Nothing )

View file

@ -0,0 +1,48 @@
module Main (..) where
import Task
import Console
import ElmTest exposing (..)
import RunLengthEncoding exposing (decode, encode)
tests : Test
tests =
suite
"RunLengthEncoding"
[ test
"encode simple"
(assertEqual "2A3B4C" (encode "AABBBCCCC"))
, test
"decode simple"
(assertEqual "AABBBCCCC" (decode "2A3B4C"))
, test
"encode with single values"
(assertEqual
"12WB12W3B24WB"
(encode "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB")
)
, test
"decode with single values"
(assertEqual
"WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB"
(decode "12WB12W3B24WB")
)
, test
"decode(encode(...)) combination"
(assertEqual
"zzz ZZ zZ"
(decode (encode "zzz ZZ zZ"))
)
, test
"encode unicode"
(assertEqual "32" (encode ""))
, test
"decode unicode"
(assertEqual "" (decode "32"))
]
port runner : Signal (Task.Task x ())
port runner =
Console.run (consoleRunner tests)

View file

@ -0,0 +1,16 @@
{
"version": "1.0.0",
"summary": "Exercism problems in Elm.",
"repository": "https://github.com/exercism/xelm.git",
"license": "BSD3",
"source-directories": [
"."
],
"exposed-modules": [],
"dependencies": {
"deadfoxygrandpa/elm-test": "3.0.1 <= v < 4.0.0",
"elm-lang/core": "2.0.0 <= v < 4.0.0",
"laszlopandy/elm-console": "1.1.0 <= v < 2.0.0"
},
"elm-version": "0.15.0 <= v < 0.17.0"
}

View file

@ -0,0 +1 @@
module Triangle (..) where

View file

@ -0,0 +1,21 @@
module Triangle (..) where
import Set
triangleKind : number -> number -> number -> Result String String
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"

View file

@ -0,0 +1,63 @@
module Main (..) where
import Task
import Console
import ElmTest exposing (..)
import Triangle exposing (triangleKind)
tests : Test
tests =
suite
"triangleKind"
[ test
"equilateral triangles have equal sides"
(assertEqual (Ok "equilateral") (triangleKind 2 2 2))
, test
"larger equilateral triangles also have equal sides"
(assertEqual (Ok "equilateral") (triangleKind 10 10 10))
, test
"isosceles triangles have last two sides equal"
(assertEqual (Ok "isosceles") (triangleKind 3 4 4))
, test
"isosceles triangles have first and last sides equal"
(assertEqual (Ok "isosceles") (triangleKind 4 3 4))
, test
"isosceles triangles have two first sides equal"
(assertEqual (Ok "isosceles") (triangleKind 4 4 3))
, test
"isosceles triangles have in fact exactly two sides equal"
(assertEqual (Ok "isosceles") (triangleKind 10 10 2))
, test
"scalene triangles have no equal sides"
(assertEqual (Ok "scalene") (triangleKind 3 4 5))
, test
"scalene triangles have no equal sides at a larger scale too"
(assertEqual (Ok "scalene") (triangleKind 10 11 12))
, test
"scalene triangles have no equal sides at a larger scale too 2"
(assertEqual (Ok "scalene") (triangleKind 5 4 2))
, test
"very small triangles are legal"
(assertEqual (Ok "scalene") (triangleKind 0.4 0.6 0.3))
, test
"triangles with no size are illegal"
(assertEqual (Err "Invalid lengths") (triangleKind 0 0 0))
, test
"triangles with negative sides are illegal"
(assertEqual (Err "Invalid lengths") (triangleKind 3 4 -5))
, test
"triangles violating triangle inequality are illegal 1"
(assertEqual (Err "Violates inequality") (triangleKind 1 1 3))
, test
"triangles violating triangle inequality are illegal 2"
(assertEqual (Err "Violates inequality") (triangleKind 2 4 2))
, test
"triangles violating triangle inequality are illegal 3"
(assertEqual (Err "Violates inequality") (triangleKind 7 3 2))
]
port runner : Signal (Task.Task x ())
port runner =
Console.run (consoleRunner tests)

View file

@ -0,0 +1,16 @@
{
"version": "1.0.0",
"summary": "Exercism problems in Elm.",
"repository": "https://github.com/exercism/xelm.git",
"license": "BSD3",
"source-directories": [
"."
],
"exposed-modules": [],
"dependencies": {
"deadfoxygrandpa/elm-test": "3.0.1 <= v < 4.0.0",
"elm-lang/core": "2.0.0 <= v < 4.0.0",
"laszlopandy/elm-console": "1.1.0 <= v < 2.0.0"
},
"elm-version": "0.15.0 <= v < 0.17.0"
}

View file

@ -0,0 +1 @@
module WordCount (..) where

View file

@ -0,0 +1,24 @@
module WordCount (..) where
import String
import Dict exposing (Dict)
import Regex
wordCount : String -> Dict String Int
wordCount sentence =
sentence
|> String.toLower
|> depunctuate
|> String.words
|> List.foldl (\w d -> Dict.update w incrMaybe d) Dict.empty
depunctuate : String -> String
depunctuate =
Regex.replace Regex.All (Regex.regex "[^a-z0-9 ]") (\_ -> "")
incrMaybe : Maybe Int -> Maybe Int
incrMaybe maybe =
(Maybe.withDefault 0 maybe) + 1 |> Just

View file

@ -0,0 +1,55 @@
module Main (..) where
import Task
import Console
import ElmTest exposing (..)
import Dict exposing (Dict)
import WordCount exposing (wordCount)
tests : Test
tests =
suite
"Hamming"
[ test
"count one word"
(assertEqual
(Dict.fromList [ ( "word", 1 ) ])
(wordCount "word")
)
, test
"count one of each word"
(assertEqual
(Dict.fromList [ ( "one", 1 ), ( "of", 1 ), ( "each", 1 ) ])
(wordCount "one of each")
)
, test
"multiple occurrences of a word"
(assertEqual
(Dict.fromList [ ( "one", 1 ), ( "fish", 4 ), ( "two", 1 ), ( "red", 1 ), ( "blue", 1 ) ])
(wordCount "one fish two fish red fish blue fish")
)
, test
"ignore punctuation"
(assertEqual
(Dict.fromList [ ( "car", 1 ), ( "carpet", 1 ), ( "as", 1 ), ( "java", 1 ), ( "javascript", 1 ) ])
(wordCount "car : carpet as java : javascript!!&@$%^&")
)
, test
"include numbers"
(assertEqual
(Dict.fromList [ ( "testing", 2 ), ( "1", 1 ), ( "2", 1 ) ])
(wordCount "testing, 1, 2 testing")
)
, test
"normalize case"
(assertEqual
(Dict.fromList [ ( "go", 3 ), ( "stop", 2 ) ])
(wordCount "go Go GO Stop stop")
)
]
port runner : Signal (Task.Task x ())
port runner =
Console.run (consoleRunner tests)

View file

@ -0,0 +1,16 @@
{
"version": "1.0.0",
"summary": "Exercism problems in Elm.",
"repository": "https://github.com/exercism/xelm.git",
"license": "BSD3",
"source-directories": [
"."
],
"exposed-modules": [],
"dependencies": {
"deadfoxygrandpa/elm-test": "3.0.1 <= v < 4.0.0",
"elm-lang/core": "2.0.0 <= v < 4.0.0",
"laszlopandy/elm-console": "1.1.0 <= v < 2.0.0"
},
"elm-version": "0.15.0 <= v < 0.17.0"
}