Skip to content

Commit 7e570ac

Browse files
add pangram (#24)
* exercise boilerplate * generate test cases * add interface file to solution * add example solution * fix config
1 parent 18cf0e0 commit 7e570ac

16 files changed

Lines changed: 1801 additions & 0 deletions

config.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@
7171
"prerequisites": [],
7272
"difficulty": 2
7373
},
74+
{
75+
"slug": "pangram",
76+
"name": "Pangram",
77+
"uuid": "ed0c465d-3561-464d-80ed-6541b2ec9410",
78+
"practices": [],
79+
"prerequisites": [],
80+
"difficulty": 2
81+
},
7482
{
7583
"slug": "strain",
7684
"name": "Strain",
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Instructions
2+
3+
Your task is to figure out if a sentence is a pangram.
4+
5+
A pangram is a sentence using every letter of the alphabet at least once.
6+
It is case insensitive, so it doesn't matter if a letter is lower-case (e.g. `k`) or upper-case (e.g. `K`).
7+
8+
For this exercise, a sentence is a pangram if it contains each of the 26 letters in the English alphabet.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Introduction
2+
3+
You work for a company that sells fonts through their website.
4+
They'd like to show a different sentence each time someone views a font on their website.
5+
To give a comprehensive sense of the font, the random sentences should use **all** the letters in the English alphabet.
6+
7+
They're running a competition to get suggestions for sentences that they can use.
8+
You're in charge of checking the submissions to see if they are valid.
9+
10+
~~~~exercism/note
11+
Pangram comes from Greek, παν γράμμα, pan gramma, which means "every letter".
12+
13+
The best known English pangram is:
14+
15+
> The quick brown fox jumps over the lazy dog.
16+
~~~~
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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
let isPangram = sentence => {
2+
let set =
3+
sentence
4+
->String.toLowerCase
5+
->String.split("")
6+
->Array.filter(c => c >= "a" && c <= "z")
7+
->Set.fromArray
8+
9+
Set.size(set) == 26
10+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let isPangram: 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/Pangram.res",
8+
"src/Pangram.resi"
9+
],
10+
"test": [
11+
"tests/Pangram_test.res"
12+
],
13+
"example": [
14+
".meta/Pangram.res",
15+
".meta/Pangram.resi"
16+
]
17+
},
18+
"blurb": "Determine if a sentence is a pangram.",
19+
"source": "Wikipedia",
20+
"source_url": "https://en.wikipedia.org/wiki/Pangram"
21+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
const sentence = JSON.stringify(c.input.sentence)
15+
return `assertEqual(~message="${c.description}", isPangram(${sentence}), ${c.expected})`
16+
}
17+
18+
generateTests(__dirname, slug, assertionFunctions, template)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
[64f61791-508e-4f5c-83ab-05de042b0149]
13+
description = "empty sentence"
14+
15+
[74858f80-4a4d-478b-8a5e-c6477e4e4e84]
16+
description = "perfect lower case"
17+
18+
[61288860-35ca-4abe-ba08-f5df76ecbdcd]
19+
description = "only lower case"
20+
21+
[6564267d-8ac5-4d29-baf2-e7d2e304a743]
22+
description = "missing the letter 'x'"
23+
24+
[c79af1be-d715-4cdb-a5f2-b2fa3e7e0de0]
25+
description = "missing the letter 'h'"
26+
27+
[d835ec38-bc8f-48e4-9e36-eb232427b1df]
28+
description = "with underscores"
29+
30+
[8cc1e080-a178-4494-b4b3-06982c9be2a8]
31+
description = "with numbers"
32+
33+
[bed96b1c-ff95-45b8-9731-fdbdcb6ede9a]
34+
description = "missing letters replaced by numbers"
35+
36+
[938bd5d8-ade5-40e2-a2d9-55a338a01030]
37+
description = "mixed case and punctuation"
38+
39+
[2577bf54-83c8-402d-a64b-a2c0f7bb213a]
40+
description = "case insensitive"
41+
include = false
42+
43+
[7138e389-83e4-4c6e-8413-1e40a0076951]
44+
description = "a-m and A-M are 26 different characters but not a pangram"
45+
reimplements = "2577bf54-83c8-402d-a64b-a2c0f7bb213a"

exercises/practice/pangram/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)