diff --git a/config.json b/config.json index ef6a26f..bc71ae9 100644 --- a/config.json +++ b/config.json @@ -148,6 +148,14 @@ "prerequisites": [], "difficulty": 2 }, + { + "slug": "isogram", + "name": "Isogram", + "uuid": "32f84294-b162-41f6-af08-41634ef7427d", + "practices": [], + "prerequisites": [], + "difficulty": 2 + }, { "slug": "leap", "name": "Leap", diff --git a/exercises/practice/isogram/.docs/instructions.md b/exercises/practice/isogram/.docs/instructions.md new file mode 100644 index 0000000..2e8df85 --- /dev/null +++ b/exercises/practice/isogram/.docs/instructions.md @@ -0,0 +1,14 @@ +# Instructions + +Determine if a word or phrase is an isogram. + +An isogram (also known as a "non-pattern word") is a word or phrase without a repeating letter, however spaces and hyphens are allowed to appear multiple times. + +Examples of isograms: + +- lumberjacks +- background +- downstream +- six-year-old + +The word _isograms_, however, is not an isogram, because the s repeats. diff --git a/exercises/practice/isogram/.gitignore b/exercises/practice/isogram/.gitignore new file mode 100644 index 0000000..6dd20ff --- /dev/null +++ b/exercises/practice/isogram/.gitignore @@ -0,0 +1,11 @@ +## -*- conf -*- +.rebar3 +_build/ +ebin/ +erl_crash.dump +rebar3.crashdump + +tmp +bin/configlet +bin/configlet.exe +CHECKLIST diff --git a/exercises/practice/isogram/.meta/config.json b/exercises/practice/isogram/.meta/config.json new file mode 100644 index 0000000..8f79a06 --- /dev/null +++ b/exercises/practice/isogram/.meta/config.json @@ -0,0 +1,19 @@ +{ + "authors": [ + "BNAndras" + ], + "files": { + "solution": [ + "src/isogram.lfe" + ], + "test": [ + "test/isogram-tests.lfe" + ], + "example": [ + ".meta/example.lfe" + ] + }, + "blurb": "Determine if a word or phrase is an isogram.", + "source": "Wikipedia", + "source_url": "https://en.wikipedia.org/wiki/Isogram" +} diff --git a/exercises/practice/isogram/.meta/example.lfe b/exercises/practice/isogram/.meta/example.lfe new file mode 100644 index 0000000..9606eed --- /dev/null +++ b/exercises/practice/isogram/.meta/example.lfe @@ -0,0 +1,12 @@ +(defmodule isogram + (export (isogram? 1))) + +(defun isogram? (phrase) + (let* ((lowered (string:to_lower phrase)) + (chars (re:replace lowered + "[^a-z]" + "" + '(#(return list) global))) + (uniques (lists:usort chars))) + (=:= (length chars) (length uniques)))) + diff --git a/exercises/practice/isogram/.meta/tests.toml b/exercises/practice/isogram/.meta/tests.toml new file mode 100644 index 0000000..ba04c66 --- /dev/null +++ b/exercises/practice/isogram/.meta/tests.toml @@ -0,0 +1,52 @@ +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. + +[a0e97d2d-669e-47c7-8134-518a1e2c4555] +description = "empty string" + +[9a001b50-f194-4143-bc29-2af5ec1ef652] +description = "isogram with only lower case characters" + +[8ddb0ca3-276e-4f8b-89da-d95d5bae78a4] +description = "word with one duplicated character" + +[6450b333-cbc2-4b24-a723-0b459b34fe18] +description = "word with one duplicated character from the end of the alphabet" + +[a15ff557-dd04-4764-99e7-02cc1a385863] +description = "longest reported english isogram" + +[f1a7f6c7-a42f-4915-91d7-35b2ea11c92e] +description = "word with duplicated character in mixed case" + +[14a4f3c1-3b47-4695-b645-53d328298942] +description = "word with duplicated character in mixed case, lowercase first" + +[423b850c-7090-4a8a-b057-97f1cadd7c42] +description = "hypothetical isogrammic word with hyphen" + +[93dbeaa0-3c5a-45c2-8b25-428b8eacd4f2] +description = "hypothetical word with duplicated character following hyphen" + +[36b30e5c-173f-49c6-a515-93a3e825553f] +description = "isogram with duplicated hyphen" + +[cdabafa0-c9f4-4c1f-b142-689c6ee17d93] +description = "made-up name that is an isogram" + +[5fc61048-d74e-48fd-bc34-abfc21552d4d] +description = "duplicated character in the middle" + +[310ac53d-8932-47bc-bbb4-b2b94f25a83e] +description = "same first and last characters" + +[0d0b8644-0a1e-4a31-a432-2b3ee270d847] +description = "word with duplicated character and with two hyphens" diff --git a/exercises/practice/isogram/Makefile b/exercises/practice/isogram/Makefile new file mode 100644 index 0000000..fbb5a7d --- /dev/null +++ b/exercises/practice/isogram/Makefile @@ -0,0 +1,21 @@ +ERL := $(shell which erl) +REBAR3 := $(shell which rebar3) + +null := +space := $(null) # +comma := , + +ifeq ($(ERL),) + $(error Can't find Erlang executable 'erl') +else ifeq ($(REBAR3),) + $(error Can't find rebar3) +endif + +compile: ; $(REBAR3) compile + +clean: ; $(REBAR3) clean + +.PHONY: test +test: + $(REBAR3) eunit \ + -m $(subst $(space),$(comma),$(basename $(notdir $(wildcard test/*.lfe)))) diff --git a/exercises/practice/isogram/rebar.config b/exercises/practice/isogram/rebar.config new file mode 100644 index 0000000..3025789 --- /dev/null +++ b/exercises/practice/isogram/rebar.config @@ -0,0 +1,11 @@ +{plugins, [{rebar3_lfe, "0.4.10"}]}. + +{provider_hooks, [{post, [{compile, {lfe, compile}}]}]}. + +{deps, [{lfe, "2.1.3"}]}. + +{profiles, + [{test, + [{eunit_compile_opts, [{src_dirs, ["src", "test"]}]}, + {deps, + [{ltest, "0.13.8"}]}]}]}. diff --git a/exercises/practice/isogram/rebar.lock b/exercises/practice/isogram/rebar.lock new file mode 100644 index 0000000..4583682 --- /dev/null +++ b/exercises/practice/isogram/rebar.lock @@ -0,0 +1,8 @@ +{"1.2.0", +[{<<"lfe">>,{pkg,<<"lfe">>,<<"2.1.3">>},0}]}. +[ +{pkg_hash,[ + {<<"lfe">>, <<"6EFCB2BBC1FFC21DC5D1C092F00EFDB397EAC889474AC5C86EDF78A3557CC730">>}]}, +{pkg_hash_ext,[ + {<<"lfe">>, <<"4E4BAD515A169AE418FEB7374EA1C8D741FAEA9D95E266CE343B45BCC377F55B">>}]} +]. diff --git a/exercises/practice/isogram/src/isogram.app.src b/exercises/practice/isogram/src/isogram.app.src new file mode 100644 index 0000000..3d097bc --- /dev/null +++ b/exercises/practice/isogram/src/isogram.app.src @@ -0,0 +1,11 @@ +%% -*- erlang -*- +{application, 'isogram', + [{description, ""}, + {vsn, "0.0.1"}, + {modules, + ['isogram']}, + {registered, []}, + {applications, + [kernel, stdlib]}, + {included_applications, []}, + {env, []}]}. diff --git a/exercises/practice/isogram/src/isogram.lfe b/exercises/practice/isogram/src/isogram.lfe new file mode 100644 index 0000000..0fb6f27 --- /dev/null +++ b/exercises/practice/isogram/src/isogram.lfe @@ -0,0 +1,4 @@ +(defmodule isogram + (export (isogram? 1))) + + ; Please implement the isogram? function. diff --git a/exercises/practice/isogram/test/isogram-tests.lfe b/exercises/practice/isogram/test/isogram-tests.lfe new file mode 100644 index 0000000..e8ae21b --- /dev/null +++ b/exercises/practice/isogram/test/isogram-tests.lfe @@ -0,0 +1,48 @@ +(defmodule isogram-tests + (behaviour ltest-unit) + (export all)) + +(include-lib "ltest/include/ltest-macros.lfe") + +(deftest empty-string + (is (isogram:isogram? ""))) + +(deftest isogram-with-only-lower-case-characters + (is (isogram:isogram? "isogram"))) + +(deftest word-with-one-duplicate-character + (is-not (isogram:isogram? "eleven"))) + +(deftest word-with-one-duplicated-character-from-the-end-of-the-alphabet + (is-not (isogram:isogram? "zzyzx"))) + +(deftest longest-reported-english-isogram + (is (isogram:isogram? "subdermatoglyphic"))) + +(deftest word-with-duplicated-character-in-mixed-case + (is-not (isogram:isogram? "Alphabet"))) + +(deftest word-with-duplicate-character-in-mixed-case-lowercase-first + (is-not (isogram:isogram? "alphAbet"))) + +(deftest hypothetical-isogrammic-word-with-hyphen + (is (isogram:isogram? "thumbscrew-japingly"))) + +(deftest hypothetical-isogrammic-word-with-duplicated-character-following-hyphen + (is-not (isogram:isogram? "thumbscrew-jappingly"))) + +(deftest isogram-with-duplicated-hyphen + (is (isogram:isogram? "six-year-old"))) + +(deftest made-up-name-that-is-an-isogram + (is (isogram:isogram? "Emily Jung Schwartzkopf"))) + +(deftest duplicated-character-in-the-middle + (is-not (isogram:isogram? "accentor"))) + +(deftest same-first-and-last-characters + (is-not (isogram:isogram? "angola"))) + +(deftest word-with-duplicated-character-and-with-two-hyphens + (is-not (isogram:isogram? "up-to-date"))) +