-
-
Notifications
You must be signed in to change notification settings - Fork 13
* add new practice exercise: pangram #115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3dd69e4
* initial commit
jimmytty 4fd6872
* set exercise difficulty to 2 (easy)
jimmytty ea60bb1
* add new practice exercise: pangram
jimmytty 858020b
* excluding omitted test
jimmytty 20d0e98
* slightly solution simplification
jimmytty 02a0843
* adding spaces after commas between values
jimmytty File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Instructions | ||
|
||
Your task is to figure out if a sentence is a pangram. | ||
|
||
A pangram is a sentence using every letter of the alphabet at least once. | ||
It is case insensitive, so it doesn't matter if a letter is lower-case (e.g. `k`) or upper-case (e.g. `K`). | ||
|
||
For this exercise, a sentence is a pangram if it contains each of the 26 letters in the English alphabet. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Introduction | ||
|
||
You work for a company that sells fonts through their website. | ||
They'd like to show a different sentence each time someone views a font on their website. | ||
To give a comprehensive sense of the font, the random sentences should use **all** the letters in the English alphabet. | ||
|
||
They're running a competition to get suggestions for sentences that they can use. | ||
You're in charge of checking the submissions to see if they are valid. | ||
|
||
~~~~exercism/note | ||
Pangram comes from Greek, παν γράμμα, pan gramma, which means "every letter". | ||
|
||
The best known English pangram is: | ||
|
||
> The quick brown fox jumps over the lazy dog. | ||
~~~~ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"authors": [ | ||
"jimmytty" | ||
], | ||
"files": { | ||
"solution": [ | ||
"pangram.sql" | ||
], | ||
"test": [ | ||
"pangram_test.sql" | ||
], | ||
"example": [ | ||
".meta/example.sql" | ||
] | ||
}, | ||
"blurb": "Determine if a sentence is a pangram.", | ||
"source": "Wikipedia", | ||
"source_url": "https://en.wikipedia.org/wiki/Pangram" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
UPDATE pangram | ||
SET result = ( | ||
INSTR(LOWER(sentence), 'a') > 0 | ||
AND INSTR(LOWER(sentence), 'b') > 0 | ||
AND INSTR(LOWER(sentence), 'c') > 0 | ||
AND INSTR(LOWER(sentence), 'd') > 0 | ||
AND INSTR(LOWER(sentence), 'e') > 0 | ||
AND INSTR(LOWER(sentence), 'f') > 0 | ||
AND INSTR(LOWER(sentence), 'g') > 0 | ||
AND INSTR(LOWER(sentence), 'h') > 0 | ||
AND INSTR(LOWER(sentence), 'i') > 0 | ||
AND INSTR(LOWER(sentence), 'j') > 0 | ||
AND INSTR(LOWER(sentence), 'k') > 0 | ||
AND INSTR(LOWER(sentence), 'l') > 0 | ||
AND INSTR(LOWER(sentence), 'm') > 0 | ||
AND INSTR(LOWER(sentence), 'n') > 0 | ||
AND INSTR(LOWER(sentence), 'o') > 0 | ||
AND INSTR(LOWER(sentence), 'p') > 0 | ||
AND INSTR(LOWER(sentence), 'q') > 0 | ||
AND INSTR(LOWER(sentence), 'r') > 0 | ||
AND INSTR(LOWER(sentence), 's') > 0 | ||
AND INSTR(LOWER(sentence), 't') > 0 | ||
AND INSTR(LOWER(sentence), 'u') > 0 | ||
AND INSTR(LOWER(sentence), 'v') > 0 | ||
AND INSTR(LOWER(sentence), 'w') > 0 | ||
AND INSTR(LOWER(sentence), 'x') > 0 | ||
AND INSTR(LOWER(sentence), 'y') > 0 | ||
AND INSTR(LOWER(sentence), 'z') > 0 | ||
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# 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. | ||
|
||
[64f61791-508e-4f5c-83ab-05de042b0149] | ||
description = "empty sentence" | ||
|
||
[74858f80-4a4d-478b-8a5e-c6477e4e4e84] | ||
description = "perfect lower case" | ||
|
||
[61288860-35ca-4abe-ba08-f5df76ecbdcd] | ||
description = "only lower case" | ||
|
||
[6564267d-8ac5-4d29-baf2-e7d2e304a743] | ||
description = "missing the letter 'x'" | ||
|
||
[c79af1be-d715-4cdb-a5f2-b2fa3e7e0de0] | ||
description = "missing the letter 'h'" | ||
|
||
[d835ec38-bc8f-48e4-9e36-eb232427b1df] | ||
description = "with underscores" | ||
|
||
[8cc1e080-a178-4494-b4b3-06982c9be2a8] | ||
description = "with numbers" | ||
|
||
[bed96b1c-ff95-45b8-9731-fdbdcb6ede9a] | ||
description = "missing letters replaced by numbers" | ||
|
||
[938bd5d8-ade5-40e2-a2d9-55a338a01030] | ||
description = "mixed case and punctuation" | ||
|
||
[2577bf54-83c8-402d-a64b-a2c0f7bb213a] | ||
description = "case insensitive" | ||
include = false | ||
|
||
[7138e389-83e4-4c6e-8413-1e40a0076951] | ||
description = "a-m and A-M are 26 different characters but not a pangram" | ||
reimplements = "2577bf54-83c8-402d-a64b-a2c0f7bb213a" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
DROP TABLE IF EXISTS pangram; | ||
CREATE TABLE pangram ( | ||
sentence TEXT NOT NULL, | ||
result BOOLEAN | ||
); | ||
|
||
.mode csv | ||
.import ./data.csv pangram | ||
|
||
UPDATE pangram SET result = NULL; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
DROP TABLE IF EXISTS tests; | ||
CREATE TABLE IF NOT EXISTS tests ( | ||
-- uuid and description are taken from the test.toml file | ||
uuid TEXT PRIMARY KEY, | ||
description TEXT NOT NULL, | ||
-- The following section is needed by the online test-runner | ||
status TEXT DEFAULT 'fail', | ||
message TEXT, | ||
output TEXT, | ||
test_code TEXT, | ||
task_id INTEGER DEFAULT NULL, | ||
-- Here are columns for the actual tests | ||
sentence TEXT NOT NULL, | ||
expected BOOLEAN NOT NULL | ||
); | ||
|
||
INSERT INTO tests (uuid, description, sentence, expected) | ||
VALUES | ||
('64f61791-508e-4f5c-83ab-05de042b0149','empty sentence','',false), | ||
jimmytty marked this conversation as resolved.
Show resolved
Hide resolved
|
||
('74858f80-4a4d-478b-8a5e-c6477e4e4e84','perfect lower case','abcdefghijklmnopqrstuvwxyz',true), | ||
('61288860-35ca-4abe-ba08-f5df76ecbdcd','only lower case','the quick brown fox jumps over the lazy dog',true), | ||
('6564267d-8ac5-4d29-baf2-e7d2e304a743','missing the letter ''x''','a quick movement of the enemy will jeopardize five gunboats',false), | ||
('c79af1be-d715-4cdb-a5f2-b2fa3e7e0de0','missing the letter ''h''','five boxing wizards jump quickly at it',false), | ||
('d835ec38-bc8f-48e4-9e36-eb232427b1df','with underscores','the_quick_brown_fox_jumps_over_the_lazy_dog',true), | ||
('8cc1e080-a178-4494-b4b3-06982c9be2a8','with numbers','the 1 quick brown fox jumps over the 2 lazy dogs',true), | ||
('bed96b1c-ff95-45b8-9731-fdbdcb6ede9a','missing letters replaced by numbers','7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog',false), | ||
('938bd5d8-ade5-40e2-a2d9-55a338a01030','mixed case and punctuation','"Five quacking Zephyrs jolt my wax bed."',true), | ||
('7138e389-83e4-4c6e-8413-1e40a0076951','a-m and A-M are 26 different characters but not a pangram','abcdefghijklm ABCDEFGHIJKLM',false); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
"","" | ||
"abcdefghijklmnopqrstuvwxyz","" | ||
"the quick brown fox jumps over the lazy dog","" | ||
"a quick movement of the enemy will jeopardize five gunboats","" | ||
"five boxing wizards jump quickly at it","" | ||
"the_quick_brown_fox_jumps_over_the_lazy_dog","" | ||
"the 1 quick brown fox jumps over the 2 lazy dogs","" | ||
"7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog","" | ||
"""Five quacking Zephyrs jolt my wax bed.""","" | ||
"the quick brown fox jumps over with lazy FX","" | ||
"abcdefghijklm ABCDEFGHIJKLM","" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- Schema: CREATE TABLE pangram (sentence TEXT NOT NULL, result BOOLEAN); | ||
-- Task: update pangram table and set result based on sentence. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
-- Create database: | ||
.read ./create_fixture.sql | ||
|
||
-- Read user student solution and save any output as markdown in user_output.md: | ||
.mode markdown | ||
.output user_output.md | ||
.read ./pangram.sql | ||
.output | ||
|
||
-- Create a clean testing environment: | ||
.read ./create_test_table.sql | ||
|
||
-- Comparison of user input and the tests updates the status for each test: | ||
UPDATE tests | ||
SET status = 'pass' | ||
FROM (SELECT sentence, result FROM pangram) AS actual | ||
WHERE (actual.sentence, actual.result) = (tests.sentence, tests.expected); | ||
|
||
-- Update message for failed tests to give helpful information: | ||
UPDATE tests | ||
SET message = ( | ||
'Result for "' | ||
|| actual.sentence | ||
|| '"' | ||
|| ' is <' || COALESCE(actual.result, 'NULL') | ||
|| '> but should be <' || tests.expected || '>' | ||
) | ||
FROM (SELECT sentence, result FROM pangram) AS actual | ||
WHERE actual.sentence = tests.sentence AND tests.status = 'fail'; | ||
|
||
-- Save results to ./output.json (needed by the online test-runner) | ||
.mode json | ||
.once './output.json' | ||
SELECT description, status, message, output, test_code, task_id | ||
FROM tests; | ||
|
||
-- Display test results in readable form for the student: | ||
.mode table | ||
SELECT description, status, message | ||
FROM tests; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.