Skip to content

Commit 3c4bc4a

Browse files
Add isogram exercise (#13)
* isogram * small formatting tweaks
1 parent 44daa31 commit 3c4bc4a

7 files changed

Lines changed: 120 additions & 0 deletions

File tree

config.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,14 @@
101101
"practices": [],
102102
"prerequisites": [],
103103
"difficulty": 4
104+
},
105+
{
106+
"slug": "isogram",
107+
"name": "Isogram",
108+
"uuid": "cae3e1d4-d352-4a7a-8b5f-dc43712bad98",
109+
"practices": [],
110+
"prerequisites": [],
111+
"difficulty": 2
104112
}
105113
]
106114
},
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Instructions
2+
3+
Determine if a word or phrase is an isogram.
4+
5+
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.
6+
7+
Examples of isograms:
8+
9+
- lumberjacks
10+
- background
11+
- downstream
12+
- six-year-old
13+
14+
The word _isograms_, however, is not an isogram, because the s repeats.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"authors": [
3+
"quintuple-mallard"
4+
],
5+
"files": {
6+
"solution": [
7+
"isogram.nu"
8+
],
9+
"test": [
10+
"tests.nu"
11+
],
12+
"example": [
13+
".meta/example.nu"
14+
]
15+
},
16+
"blurb": "Determine if a word or phrase is an isogram.",
17+
"source": "Wikipedia",
18+
"source_url": "https://en.wikipedia.org/wiki/Isogram"
19+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
def clean [phrase: string] {
2+
$phrase | str downcase | split chars | where $it in 'abcdefghijklmnopqrstuvwxyz'
3+
}
4+
export def is_isogram [phrase: string] {
5+
let phrase = clean $phrase
6+
($phrase | uniq) == $phrase
7+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# This is an auto-generated file.
2+
#
3+
# Regenerating this file via `configlet sync` will:
4+
# - Recreate every `description` key/value pair
5+
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
6+
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
7+
# - Preserve any other key/value pair
8+
#
9+
# As user-added comments (using the # character) will be removed when this file
10+
# is regenerated, comments can be added via a `comment` key.
11+
12+
[a0e97d2d-669e-47c7-8134-518a1e2c4555]
13+
description = "empty string"
14+
15+
[9a001b50-f194-4143-bc29-2af5ec1ef652]
16+
description = "isogram with only lower case characters"
17+
18+
[8ddb0ca3-276e-4f8b-89da-d95d5bae78a4]
19+
description = "word with one duplicated character"
20+
21+
[6450b333-cbc2-4b24-a723-0b459b34fe18]
22+
description = "word with one duplicated character from the end of the alphabet"
23+
24+
[a15ff557-dd04-4764-99e7-02cc1a385863]
25+
description = "longest reported english isogram"
26+
27+
[f1a7f6c7-a42f-4915-91d7-35b2ea11c92e]
28+
description = "word with duplicated character in mixed case"
29+
30+
[14a4f3c1-3b47-4695-b645-53d328298942]
31+
description = "word with duplicated character in mixed case, lowercase first"
32+
33+
[423b850c-7090-4a8a-b057-97f1cadd7c42]
34+
description = "hypothetical isogrammic word with hyphen"
35+
36+
[93dbeaa0-3c5a-45c2-8b25-428b8eacd4f2]
37+
description = "hypothetical word with duplicated character following hyphen"
38+
39+
[36b30e5c-173f-49c6-a515-93a3e825553f]
40+
description = "isogram with duplicated hyphen"
41+
42+
[cdabafa0-c9f4-4c1f-b142-689c6ee17d93]
43+
description = "made-up name that is an isogram"
44+
45+
[5fc61048-d74e-48fd-bc34-abfc21552d4d]
46+
description = "duplicated character in the middle"
47+
48+
[310ac53d-8932-47bc-bbb4-b2b94f25a83e]
49+
description = "same first and last characters"
50+
51+
[0d0b8644-0a1e-4a31-a432-2b3ee270d847]
52+
description = "word with duplicated character and with two hyphens"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export def is_isogram [phrase: string] {
2+
error make {msg: "Please implement is_isogram"}
3+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use isogram.nu is_isogram
2+
use std/assert
3+
4+
assert equal (is_isogram "") true
5+
assert equal (is_isogram "isogram") true
6+
assert equal (is_isogram "eleven") false
7+
assert equal (is_isogram "zzyzx") false
8+
assert equal (is_isogram "subdermatoglyphic") true
9+
assert equal (is_isogram "Alphabet") false
10+
assert equal (is_isogram "alphAbet") false
11+
assert equal (is_isogram "thumbscrew-japingly") true
12+
assert equal (is_isogram "thumbscrew-jappingly") false
13+
assert equal (is_isogram "six-year-old") true
14+
assert equal (is_isogram "Emily Jung Schwartzkopf") true
15+
assert equal (is_isogram "accentor") false
16+
assert equal (is_isogram "angola") false
17+
assert equal (is_isogram "up-to-date") false

0 commit comments

Comments
 (0)