Parallel Letter Frequency
This commit is contained in:
parent
3ca9867a11
commit
af89290bbc
45 changed files with 2862 additions and 0 deletions
19
sqlite/hello-world/.exercism/config.json
Normal file
19
sqlite/hello-world/.exercism/config.json
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"authors": [
|
||||
"vaeng"
|
||||
],
|
||||
"files": {
|
||||
"solution": [
|
||||
"hello-world.sql"
|
||||
],
|
||||
"test": [
|
||||
"hello-world_test.sql"
|
||||
],
|
||||
"example": [
|
||||
".meta/example.sql"
|
||||
]
|
||||
},
|
||||
"blurb": "Exercism's classic introductory exercise. Just say \"Hello, World!\".",
|
||||
"source": "This is an exercise to introduce users to using Exercism",
|
||||
"source_url": "https://en.wikipedia.org/wiki/%22Hello,_world!%22_program"
|
||||
}
|
||||
40
sqlite/hello-world/HELP.md
Normal file
40
sqlite/hello-world/HELP.md
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
# Help
|
||||
|
||||
## Running the tests
|
||||
|
||||
Navigate to the directory containing the appropriate `${slug}_test.sql` file, where `${slug}` is the name of the exercise, using hyphens instead of spaces and all lowercase (e.g. `hello-world_test.sql` for the `Hello World` exercise).
|
||||
|
||||
```bash
|
||||
sqlite3 -bail < ${slug}_test.sql
|
||||
```
|
||||
|
||||
You can use `SELECT` statements for debugging.
|
||||
The output will be forwarded to `user_output.md` and shown in the web-editor if tests fail.
|
||||
|
||||
You can find more information in the [sqlite track docs about testing](https://exercism.org/docs/tracks/sqlite/tests).
|
||||
|
||||
## Submitting your solution
|
||||
|
||||
You can submit your solution using the `exercism submit hello-world.sql` command.
|
||||
This command will upload your solution to the Exercism website and print the solution page's URL.
|
||||
|
||||
It's possible to submit an incomplete solution which allows you to:
|
||||
|
||||
- See how others have completed the exercise
|
||||
- Request help from a mentor
|
||||
|
||||
## Need to get help?
|
||||
|
||||
If you'd like help solving the exercise, check the following pages:
|
||||
|
||||
- The [SQLite track's documentation](https://exercism.org/docs/tracks/sqlite)
|
||||
- The [SQLite track's programming category on the forum](https://forum.exercism.org/c/programming/sqlite)
|
||||
- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5)
|
||||
- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs)
|
||||
|
||||
Should those resources not suffice, you could submit your (incomplete) solution to request mentoring.
|
||||
|
||||
If you're stuck on something, it may help to look at some of the [available resources](https://exercism.org/docs/tracks/sqlite/resources) or ask [The Exercism Community on Discord](https://exercism.org/r/discord).
|
||||
|
||||
Additionally, [StackOverflow](http://stackoverflow.com/questions/tagged/sqlite) is a good spot to search for your problem/question to see if it has been answered already.
|
||||
If not, you can always [ask](https://stackoverflow.com/help/how-to-ask) or [answer](https://stackoverflow.com/help/how-to-answer) someone else's question.
|
||||
31
sqlite/hello-world/README.md
Normal file
31
sqlite/hello-world/README.md
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
# Hello World
|
||||
|
||||
Welcome to Hello World on Exercism's SQLite Track.
|
||||
If you need help running the tests or submitting your code, check out `HELP.md`.
|
||||
|
||||
## Instructions
|
||||
|
||||
The classical introductory exercise.
|
||||
Just say "Hello, World!".
|
||||
|
||||
["Hello, World!"][hello-world] is the traditional first program for beginning programming in a new language or environment.
|
||||
|
||||
The objectives are simple:
|
||||
|
||||
- Modify the provided code so that it produces the string "Hello, World!".
|
||||
- Run the test suite and make sure that it succeeds.
|
||||
- Submit your solution and check it at the website.
|
||||
|
||||
If everything goes well, you will be ready to fetch your first real exercise.
|
||||
|
||||
[hello-world]: https://en.wikipedia.org/wiki/%22Hello,_world!%22_program
|
||||
|
||||
## Source
|
||||
|
||||
### Created by
|
||||
|
||||
- @vaeng
|
||||
|
||||
### Based on
|
||||
|
||||
This is an exercise to introduce users to using Exercism - https://en.wikipedia.org/wiki/%22Hello,_world!%22_program
|
||||
3
sqlite/hello-world/create_fixture.sql
Normal file
3
sqlite/hello-world/create_fixture.sql
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
DROP TABLE IF EXISTS hello_world;
|
||||
|
||||
CREATE TABLE hello_world (greeting TEXT);
|
||||
4
sqlite/hello-world/hello-world.sql
Normal file
4
sqlite/hello-world/hello-world.sql
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
INSERT INTO
|
||||
hello_world (greeting)
|
||||
VALUES
|
||||
('Hello, World!');
|
||||
28
sqlite/hello-world/hello-world_test.sql
Normal file
28
sqlite/hello-world/hello-world_test.sql
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
-- Setup test table and read in student solution:
|
||||
.read ./test_setup.sql
|
||||
-- Test cases:
|
||||
INSERT INTO
|
||||
tests (name, uuid, expected)
|
||||
VALUES
|
||||
(
|
||||
'Say Hi!',
|
||||
'af9ffe10-dc13-42d8-a742-e7bdafac449d',
|
||||
'Hello, World!'
|
||||
);
|
||||
|
||||
-- Comparison of user input and the tests updates the status for each test:
|
||||
UPDATE tests
|
||||
SET
|
||||
status = 'pass'
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
greeting
|
||||
FROM
|
||||
hello_world
|
||||
) AS actual
|
||||
WHERE
|
||||
actual.greeting = tests.expected;
|
||||
|
||||
-- Write results and debug info:
|
||||
.read ./test_reporter.sql
|
||||
37
sqlite/hello-world/test_reporter.sql
Normal file
37
sqlite/hello-world/test_reporter.sql
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
-- Upadate message for failed tests to give helpful information:
|
||||
UPDATE tests
|
||||
SET
|
||||
message = (
|
||||
'Greeting' || ' is "' || COALESCE(actual.greeting, 'NULL') || '" but should be "' || tests.expected || '"'
|
||||
)
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
greeting
|
||||
FROM
|
||||
hello_world
|
||||
) AS actual
|
||||
WHERE
|
||||
tests.status = 'fail';
|
||||
|
||||
-- Save results to ./output.json (needed by the online test-runner)
|
||||
.mode json
|
||||
.once './output.json'
|
||||
SELECT
|
||||
name,
|
||||
status,
|
||||
message,
|
||||
output,
|
||||
test_code,
|
||||
task_id
|
||||
FROM
|
||||
tests;
|
||||
|
||||
-- Display test results in readable form for the student:
|
||||
.mode table
|
||||
SELECT
|
||||
name,
|
||||
status,
|
||||
message
|
||||
FROM
|
||||
tests;
|
||||
23
sqlite/hello-world/test_setup.sql
Normal file
23
sqlite/hello-world/test_setup.sql
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
-- 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 ./hello-world.sql
|
||||
.output
|
||||
-- Create a clean testing environment:
|
||||
DROP TABLE IF EXISTS main.tests;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS main.tests (
|
||||
-- uuid and name (description) are taken from the test.toml file
|
||||
uuid TEXT PRIMARY KEY,
|
||||
name 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
|
||||
expected TEXT NOT NULL
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue