Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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
matrix TEXT NOT NULL, -- json array of arrays
expected TEXT NOT NULL -- json array of objects
);

INSERT INTO
tests (uuid, description, matrix, expected)
VALUES
{%- for case in cases %}
(
'{{ case["uuid"] }}',
'{{ case["description"] }}',
'{{ case["input"]["matrix"] | tojson }}',
'{{ case["expected"] | tojson }}'
{%- if loop.last %}
);
{%- else %}
),
{%- endif %}
{%- endfor %}
3 changes: 3 additions & 0 deletions exercises/practice/saddle-points/.meta/template.data.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{%- for case in cases -%}
"{{ case["input"]["matrix"] | tojson }}",""
{% endfor %}
18 changes: 9 additions & 9 deletions exercises/practice/saddle-points/data.csv
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"[[9,8,7],[5,3,2],[6,6,7]]",
"[[]]",
"[[1,2,3],[3,1,2],[2,3,1]]",
"[[4,5,4],[3,5,5],[1,5,4]]",
"[[6,7,8],[5,5,5],[7,5,6]]",
"[[8,7,9],[6,7,6],[3,2,5]]",
"[[3,1,3],[3,2,4]]",
"[[2],[1],[4],[1]]",
"[[2,5,3,5]]",
"[[9,8,7],[5,3,2],[6,6,7]]",""
"[[]]",""
"[[1,2,3],[3,1,2],[2,3,1]]",""
"[[4,5,4],[3,5,5],[1,5,4]]",""
"[[6,7,8],[5,5,5],[7,5,6]]",""
"[[8,7,9],[6,7,6],[3,2,5]]",""
"[[3,1,3],[3,2,4]]",""
"[[2],[1],[4],[1]]",""
"[[2,5,3,5]]",""
44 changes: 44 additions & 0 deletions exercises/practice/say/.meta/template.create_test_table.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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
number INTEGER NOT NULL,
expected_result TEXT,
expected_error TEXT
);

INSERT INTO
tests (
uuid,
description,
number,
expected_result,
expected_error
)
VALUES
{%- for case in cases %}
(
'{{ case["uuid"] }}',
'{{ case["description"] }}',
{{ case["input"]["number"] }},
{%- if not case["expect_error"] %}
'{{ case["expected"] }}',
{%- else %}
NULL,
{%- endif %}
{{ case.get("expect_error_msg") | quote }}
{%- if loop.last %}
);
{%- else %}
),
{%- endif %}
{%- endfor %}
3 changes: 3 additions & 0 deletions exercises/practice/say/.meta/template.data.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{%- for case in cases -%}
{{ [case["input"]["number"]] | tocsv }},""
{% endfor %}
38 changes: 19 additions & 19 deletions exercises/practice/say/data.csv
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
0,,
1,,
14,,
20,,
22,,
30,,
99,,
100,,
123,,
200,,
999,,
1000,,
1234,,
1000000,,
1002345,,
1000000000,,
987654321123,,
-1,,
1000000000000,,
0,""
1,""
14,""
20,""
22,""
30,""
99,""
100,""
123,""
200,""
999,""
1000,""
1234,""
1000000,""
1002345,""
1000000000,""
987654321123,""
-1,""
1000000000000,""
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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
word TEXT NOT NULL,
expected INTEGER NOT NULL
);

INSERT INTO
tests (uuid, description, word, expected)
VALUES
{%- for case in cases %}
(
'{{ case["uuid"] }}',
'{{ case["description"] }}',
'{{ case["input"]["word"] }}',
{{ case["expected"] }}
{%- if loop.last %}
);
{%- else %}
),
{%- endif %}
{%- endfor %}
3 changes: 3 additions & 0 deletions exercises/practice/scrabble-score/.meta/template.data.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{%- for case in cases -%}
{{ [case["input"]["word"]] | tocsv }},""
{% endfor %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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
number INTEGER NOT NULL,
expected TEXT NOT NULL
);

INSERT INTO
tests (uuid, description, number, expected)
VALUES
{%- for case in cases %}
(
'{{ case["uuid"] }}',
'{{ case["description"] }}',
{{ case["input"]["number"] }},
'{{ case["expected"] | join(", ") }}'
{%- if loop.last %}
);
{%- else %}
),
{%- endif %}
{%- endfor %}
3 changes: 3 additions & 0 deletions exercises/practice/secret-handshake/.meta/template.data.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{%- for case in cases -%}
{{ [case["input"]["number"]] | tocsv }},""
{% endfor %}
51 changes: 51 additions & 0 deletions exercises/practice/series/.meta/template.create_test_table.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
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
input TEXT NOT NULL,
slice_length INTEGER NOT NULL,
expected_result TEXT,
expected_error TEXT
);

INSERT INTO
tests (
uuid,
description,
input,
slice_length,
expected_result,
expected_error
)
VALUES
{%- for case in cases %}
(
'{{ case["uuid"] }}',
'{{ case["description"] }}',
'{{ case["input"]["series"] }}',
{{ case["input"]["sliceLength"] }},
{%- if not case["expect_error"] %}
'{{ case["expected"] | join("\n") }}',
{%- else %}
NULL,
{%- endif %}
{{ case.get("expect_error_msg") | quote }}
{%- if loop.last %}
);
{%- else %}
),
{%- endif %}
{%- endfor %}

UPDATE tests
SET
expected_result = REPLACE(expected_result, '\n', CHAR(10));
3 changes: 3 additions & 0 deletions exercises/practice/series/.meta/template.data.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{%- for case in cases -%}
{{ [case["input"]["series"], case["input"]["sliceLength"]] | tocsv }},""
{% endfor %}
21 changes: 17 additions & 4 deletions exercises/practice/series/create_test_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ VALUES
'slices of one from two',
'12',
1,
'1\n2',
'1
2',
NULL
),
(
Expand All @@ -56,23 +57,35 @@ VALUES
'slices of two overlap',
'9142',
2,
'91\n14\n42',
'91
14
42',
NULL
),
(
'8e17148d-ba0a-4007-a07f-d7f87015d84c',
'slices can include duplicates',
'777777',
3,
'777\n777\n777\n777',
'777
777
777
777',
NULL
),
(
'bd5b085e-f612-4f81-97a8-6314258278b0',
'slices of a long series',
'918493904243',
5,
'91849\n18493\n84939\n49390\n93904\n39042\n90424\n04243',
'91849
18493
84939
49390
93904
39042
90424
04243',
NULL
),
(
Expand Down
22 changes: 11 additions & 11 deletions exercises/practice/series/data.csv
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"1",1,,
"12",1,,
"35",2,,
"9142",2,,
"777777",3,,
"918493904243",5,,
"12345",6,,
"12345",42,,
"12345",0,,
"123",-1,,
"",1,,
"1",1,""
"12",1,""
"35",2,""
"9142",2,""
"777777",3,""
"918493904243",5,""
"12345",6,""
"12345",42,""
"12345",0,""
"123",-1,""
"",1,""
30 changes: 30 additions & 0 deletions exercises/practice/sieve/.meta/template.create_test_table.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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
"limit" INTEGER NOT NULL,
expected TEXT NOT NULL
);

INSERT INTO tests (uuid, description, "limit", expected)
VALUES
{%- for case in cases %}
(
'{{ case["uuid"] }}',
'{{ case["description"] }}',
{{ case["input"]["limit"] }},
'{{ case["expected"] | join(", ") }}'
{%- if loop.last %}
);
{%- else %}
),
{%- endif %}
{%- endfor %}
3 changes: 3 additions & 0 deletions exercises/practice/sieve/.meta/template.data.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{%- for case in cases -%}
{{ [case["input"]["limit"]] | tocsv }},""
{% endfor %}
Loading