Skip to content

Commit 39e058d

Browse files
add isogram (#29)
* exercise boilerplate * example solution
1 parent 8c69caf commit 39e058d

15 files changed

Lines changed: 1820 additions & 0 deletions

File tree

config.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@
7777
"prerequisites": [],
7878
"difficulty": 2
7979
},
80+
{
81+
"slug": "isogram",
82+
"name": "Isogram",
83+
"uuid": "7cf8a5d3-2b4e-4f9d-bd01-9badc2dc82e5",
84+
"practices": [],
85+
"prerequisites": [],
86+
"difficulty": 2
87+
},
8088
{
8189
"slug": "leap",
8290
"name": "Leap",
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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
**/*.res.js
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
let isIsogram = phrase => {
2+
let charSet = Set.make()
3+
4+
phrase
5+
->String.toLowerCase
6+
->String.split("")
7+
->Array.every(c => {
8+
if c == " " || c == "-" {
9+
true
10+
} else if charSet->Set.has(c) {
11+
false
12+
} else {
13+
charSet->Set.add(c)
14+
true
15+
}
16+
})
17+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let isIsogram: string => bool
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"authors": [
3+
"therealowenrees"
4+
],
5+
"files": {
6+
"solution": [
7+
"src/Isogram.res",
8+
"src/Isogram.resi"
9+
],
10+
"test": [
11+
"tests/Isogram_test.res"
12+
],
13+
"example": [
14+
".meta/Isogram.res",
15+
".meta/Isogram.resi"
16+
]
17+
},
18+
"blurb": "Determine if a word or phrase is an isogram.",
19+
"source": "Wikipedia",
20+
"source_url": "https://en.wikipedia.org/wiki/Isogram"
21+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import path from 'node:path';
2+
import { fileURLToPath } from 'node:url';
3+
import { assertEqual } from "../../../../test_generator/assertions.js";
4+
import { generateTests } from '../../../../test_generator/testGenerator.js';
5+
6+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
7+
const slug = path.basename(path.resolve(__dirname, '..'))
8+
9+
// EDIT THIS WITH YOUR ASSERTIONS
10+
export const assertionFunctions = [ assertEqual ]
11+
12+
// EDIT THIS WITH YOUR TEST TEMPLATES
13+
export const template = (c) => {
14+
return `assertEqual(~message="${c.description}", isIsogram("${c.input.phrase}"), ${c.expected})`
15+
}
16+
17+
generateTests(__dirname, slug, assertionFunctions, template)
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"

exercises/practice/isogram/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Exercism
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)