Skip to content

Commit e080f45

Browse files
authored
Add new practice exercise: pangram (#115)
1 parent 676ad31 commit e080f45

File tree

11 files changed

+215
-0
lines changed

11 files changed

+215
-0
lines changed

config.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@
106106
"prerequisites": [],
107107
"difficulty": 2
108108
},
109+
{
110+
"slug": "pangram",
111+
"name": "Pangram",
112+
"uuid": "f11e9d34-d454-42a8-bd2f-d1a8b6000975",
113+
"practices": [],
114+
"prerequisites": [],
115+
"difficulty": 2
116+
},
109117
{
110118
"slug": "raindrops",
111119
"name": "Raindrops",
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: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"authors": [
3+
"jimmytty"
4+
],
5+
"files": {
6+
"solution": [
7+
"pangram.sql"
8+
],
9+
"test": [
10+
"pangram_test.sql"
11+
],
12+
"example": [
13+
".meta/example.sql"
14+
]
15+
},
16+
"blurb": "Determine if a sentence is a pangram.",
17+
"source": "Wikipedia",
18+
"source_url": "https://en.wikipedia.org/wiki/Pangram"
19+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
UPDATE pangram
2+
SET result = (
3+
INSTR(LOWER(sentence), 'a')
4+
AND INSTR(LOWER(sentence), 'b')
5+
AND INSTR(LOWER(sentence), 'c')
6+
AND INSTR(LOWER(sentence), 'd')
7+
AND INSTR(LOWER(sentence), 'e')
8+
AND INSTR(LOWER(sentence), 'f')
9+
AND INSTR(LOWER(sentence), 'g')
10+
AND INSTR(LOWER(sentence), 'h')
11+
AND INSTR(LOWER(sentence), 'i')
12+
AND INSTR(LOWER(sentence), 'j')
13+
AND INSTR(LOWER(sentence), 'k')
14+
AND INSTR(LOWER(sentence), 'l')
15+
AND INSTR(LOWER(sentence), 'm')
16+
AND INSTR(LOWER(sentence), 'n')
17+
AND INSTR(LOWER(sentence), 'o')
18+
AND INSTR(LOWER(sentence), 'p')
19+
AND INSTR(LOWER(sentence), 'q')
20+
AND INSTR(LOWER(sentence), 'r')
21+
AND INSTR(LOWER(sentence), 's')
22+
AND INSTR(LOWER(sentence), 't')
23+
AND INSTR(LOWER(sentence), 'u')
24+
AND INSTR(LOWER(sentence), 'v')
25+
AND INSTR(LOWER(sentence), 'w')
26+
AND INSTR(LOWER(sentence), 'x')
27+
AND INSTR(LOWER(sentence), 'y')
28+
AND INSTR(LOWER(sentence), 'z')
29+
);
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"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
DROP TABLE IF EXISTS pangram;
2+
CREATE TABLE pangram (
3+
sentence TEXT NOT NULL,
4+
result BOOLEAN
5+
);
6+
7+
.mode csv
8+
.import ./data.csv pangram
9+
10+
UPDATE pangram SET result = NULL;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
DROP TABLE IF EXISTS tests;
2+
CREATE TABLE IF NOT EXISTS tests (
3+
-- uuid and description are taken from the test.toml file
4+
uuid TEXT PRIMARY KEY,
5+
description TEXT NOT NULL,
6+
-- The following section is needed by the online test-runner
7+
status TEXT DEFAULT 'fail',
8+
message TEXT,
9+
output TEXT,
10+
test_code TEXT,
11+
task_id INTEGER DEFAULT NULL,
12+
-- Here are columns for the actual tests
13+
sentence TEXT NOT NULL,
14+
expected BOOLEAN NOT NULL
15+
);
16+
17+
INSERT INTO tests (uuid, description, sentence, expected)
18+
VALUES
19+
('64f61791-508e-4f5c-83ab-05de042b0149', 'empty sentence', '', false),
20+
('74858f80-4a4d-478b-8a5e-c6477e4e4e84', 'perfect lower case', 'abcdefghijklmnopqrstuvwxyz', true),
21+
('61288860-35ca-4abe-ba08-f5df76ecbdcd', 'only lower case', 'the quick brown fox jumps over the lazy dog', true),
22+
('6564267d-8ac5-4d29-baf2-e7d2e304a743', 'missing the letter ''x''', 'a quick movement of the enemy will jeopardize five gunboats', false),
23+
('c79af1be-d715-4cdb-a5f2-b2fa3e7e0de0', 'missing the letter ''h''', 'five boxing wizards jump quickly at it', false),
24+
('d835ec38-bc8f-48e4-9e36-eb232427b1df', 'with underscores', 'the_quick_brown_fox_jumps_over_the_lazy_dog', true),
25+
('8cc1e080-a178-4494-b4b3-06982c9be2a8', 'with numbers', 'the 1 quick brown fox jumps over the 2 lazy dogs', true),
26+
('bed96b1c-ff95-45b8-9731-fdbdcb6ede9a', 'missing letters replaced by numbers', '7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog', false),
27+
('938bd5d8-ade5-40e2-a2d9-55a338a01030', 'mixed case and punctuation', '"Five quacking Zephyrs jolt my wax bed."', true),
28+
('7138e389-83e4-4c6e-8413-1e40a0076951', 'a-m and A-M are 26 different characters but not a pangram', 'abcdefghijklm ABCDEFGHIJKLM', false);

exercises/practice/pangram/data.csv

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"",""
2+
"abcdefghijklmnopqrstuvwxyz",""
3+
"the quick brown fox jumps over the lazy dog",""
4+
"a quick movement of the enemy will jeopardize five gunboats",""
5+
"five boxing wizards jump quickly at it",""
6+
"the_quick_brown_fox_jumps_over_the_lazy_dog",""
7+
"the 1 quick brown fox jumps over the 2 lazy dogs",""
8+
"7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog",""
9+
"""Five quacking Zephyrs jolt my wax bed.""",""
10+
"abcdefghijklm ABCDEFGHIJKLM",""
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- Schema: CREATE TABLE pangram (sentence TEXT NOT NULL, result BOOLEAN);
2+
-- Task: update pangram table and set result based on sentence.

0 commit comments

Comments
 (0)