From 048c85f1dd933a00af845f405836fd2cb54dc8d3 Mon Sep 17 00:00:00 2001 From: admclamb Date: Tue, 12 May 2026 22:39:10 -0400 Subject: [PATCH 1/3] Add fizzbuzz --- Database/Fixtures/dev/0002-Problems.sql | 49 ++++++++ Database/Fixtures/dev/0003-TestSuites.sql | 114 +++++++++++++++++++ Database/Fixtures/dev/0004-ProblemSetups.sql | 77 +++++++++++++ 3 files changed, 240 insertions(+) diff --git a/Database/Fixtures/dev/0002-Problems.sql b/Database/Fixtures/dev/0002-Problems.sql index 7be6c4f..807b7e9 100644 --- a/Database/Fixtures/dev/0002-Problems.sql +++ b/Database/Fixtures/dev/0002-Problems.sql @@ -35,4 +35,53 @@ SELECT p.id, t.id FROM problems p JOIN tags t ON t.value IN ('Math', 'String') WHERE p.slug = 'hello-or-goodbye' +ON CONFLICT DO NOTHING; + +INSERT INTO problems ( + id, title, slug, question, difficulty, status_id, version, created_on, created_by_id +) +SELECT + gen_random_uuid(), + 'Fizz or Buzz', + 'fizz-or-buzz', + 'Given an integer `n`, return `"fizzbuzz"` if `n` is divisible by **both** 3 and 5, `"fizz"` if divisible by only 3, `"buzz"` if divisible by only 5, or `n` as a string if it is not divisible by 3 or 5. + +**Example 1:** + +> **Input**: `n = 3` +> **Output**: `"fizz"` + +**Example 2:** + +> **Input**: `n = 5` +> **Output**: `"buzz"` + +**Example 3:** + +> **Input**: `n = 15` +> **Output**: `"fizzbuzz"` + +**Example 4:** + +> **Input**: `n = 7` +> **Output**: `"7"` + +**Constraints:** + +- `-10^9 <= n <= 10^9` +', + 500, + ps.id, + 1, + NOW(), + NULL +FROM problem_statuses ps +WHERE ps.name = 'Published' +ON CONFLICT (slug) DO NOTHING; + +INSERT INTO problem_tags (problem_id, tag_id) +SELECT p.id, t.id +FROM problems p +JOIN tags t ON t.value IN ('Math', 'String') +WHERE p.slug = 'fizz-or-buzz' ON CONFLICT DO NOTHING; \ No newline at end of file diff --git a/Database/Fixtures/dev/0003-TestSuites.sql b/Database/Fixtures/dev/0003-TestSuites.sql index 0e56f0a..c95da88 100644 --- a/Database/Fixtures/dev/0003-TestSuites.sql +++ b/Database/Fixtures/dev/0003-TestSuites.sql @@ -92,4 +92,118 @@ BEGIN END IF; END; +$$; + +DO $$ +BEGIN + IF NOT EXISTS ( + SELECT 1 FROM test_suites WHERE name = 'Fizz or Buzz hidden tests' + ) THEN + + INSERT INTO test_cases_inputs_value_types (name) + VALUES ('integer') + ON CONFLICT (name) DO NOTHING; + + WITH value_type AS ( + SELECT id FROM test_cases_inputs_value_types WHERE name = 'integer' + ), + output_value_type AS ( + SELECT id FROM test_cases_output_value_types WHERE name = 'String' + ), + suite_type_hidden AS ( + SELECT id FROM test_suite_types WHERE name = 'Hidden' + ), + hidden_suite AS ( + INSERT INTO test_suites (name, description, test_suite_type_id) + SELECT 'Fizz or Buzz hidden tests', 'Hidden edge cases for Fizz or Buzz', suite_type_hidden.id + FROM suite_type_hidden + RETURNING id + ), + tc_3 AS ( + INSERT INTO test_cases (test_suite_id, name, description) + SELECT hidden_suite.id, 'Divisible By Three', 'Input: n = 3' FROM hidden_suite + RETURNING id + ), + tc_5 AS ( + INSERT INTO test_cases (test_suite_id, name, description) + SELECT hidden_suite.id, 'Divisible By Five', 'Input: n = 5' FROM hidden_suite + RETURNING id + ), + tc_15 AS ( + INSERT INTO test_cases (test_suite_id, name, description) + SELECT hidden_suite.id, 'Divisible By Both', 'Input: n = 15' FROM hidden_suite + RETURNING id + ), + tc_7 AS ( + INSERT INTO test_cases (test_suite_id, name, description) + SELECT hidden_suite.id, 'Not Divisible', 'Input: n = 7' FROM hidden_suite + RETURNING id + ), + tc_0 AS ( + INSERT INTO test_cases (test_suite_id, name, description) + SELECT hidden_suite.id, 'Zero', 'Input: n = 0' FROM hidden_suite + RETURNING id + ), + tc_neg3 AS ( + INSERT INTO test_cases (test_suite_id, name, description) + SELECT hidden_suite.id, 'Negative Divisible By Three', 'Input: n = -3' FROM hidden_suite + RETURNING id + ), + tc_neg5 AS ( + INSERT INTO test_cases (test_suite_id, name, description) + SELECT hidden_suite.id, 'Negative Divisible By Five', 'Input: n = -5' FROM hidden_suite + RETURNING id + ), + tc_30 AS ( + INSERT INTO test_cases (test_suite_id, name, description) + SELECT hidden_suite.id, 'Large Fizzbuzz', 'Input: n = 30' FROM hidden_suite + RETURNING id + ), + tc_2 AS ( + INSERT INTO test_cases (test_suite_id, name, description) + SELECT hidden_suite.id, 'Small Not Divisible', 'Input: n = 2' FROM hidden_suite + RETURNING id + ), + inputs AS ( + INSERT INTO test_cases_inputs (test_case_id, value, test_cases_inputs_value_type_id) + SELECT tc_3.id, '3', value_type.id FROM tc_3, value_type + UNION ALL + SELECT tc_5.id, '5', value_type.id FROM tc_5, value_type + UNION ALL + SELECT tc_15.id, '15', value_type.id FROM tc_15, value_type + UNION ALL + SELECT tc_7.id, '7', value_type.id FROM tc_7, value_type + UNION ALL + SELECT tc_0.id, '0', value_type.id FROM tc_0, value_type + UNION ALL + SELECT tc_neg3.id, '-3', value_type.id FROM tc_neg3, value_type + UNION ALL + SELECT tc_neg5.id, '-5', value_type.id FROM tc_neg5, value_type + UNION ALL + SELECT tc_30.id, '30', value_type.id FROM tc_30, value_type + UNION ALL + SELECT tc_2.id, '2', value_type.id FROM tc_2, value_type + RETURNING test_case_id + ) + INSERT INTO test_cases_expected_outputs (test_case_id, value, output_value_type_id) + SELECT tc_3.id, 'fizz', output_value_type.id FROM tc_3, output_value_type + UNION ALL + SELECT tc_5.id, 'buzz', output_value_type.id FROM tc_5, output_value_type + UNION ALL + SELECT tc_15.id, 'fizzbuzz', output_value_type.id FROM tc_15, output_value_type + UNION ALL + SELECT tc_7.id, '7', output_value_type.id FROM tc_7, output_value_type + UNION ALL + SELECT tc_0.id, 'fizzbuzz', output_value_type.id FROM tc_0, output_value_type + UNION ALL + SELECT tc_neg3.id, 'fizz', output_value_type.id FROM tc_neg3, output_value_type + UNION ALL + SELECT tc_neg5.id, 'buzz', output_value_type.id FROM tc_neg5, output_value_type + UNION ALL + SELECT tc_30.id, 'fizzbuzz', output_value_type.id FROM tc_30, output_value_type + UNION ALL + SELECT tc_2.id, '2', output_value_type.id FROM tc_2, output_value_type; + + END IF; +END; $$; \ No newline at end of file diff --git a/Database/Fixtures/dev/0004-ProblemSetups.sql b/Database/Fixtures/dev/0004-ProblemSetups.sql index a47b581..31586f8 100644 --- a/Database/Fixtures/dev/0004-ProblemSetups.sql +++ b/Database/Fixtures/dev/0004-ProblemSetups.sql @@ -73,4 +73,81 @@ FROM problem_setups ps WHERE p.slug = 'hello-or-goodbye' AND pl.name = 'JavaScript' AND plv.version = 'Node.js 22.08.0' +ON CONFLICT (problem_setup_id, test_suite_id) DO NOTHING; + +INSERT INTO problem_setups ( + problem_id, programming_language_version_id, harness_template_id, version, initial_code, function_name, created_on, created_by_id +) +SELECT + p.id, + plv.id, + 1, + 1, + 'function solution(n) { + // Your code here +} +', + 'solution', + NOW(), + NULL +FROM problems p + JOIN programming_language_versions plv + ON plv.programming_language_id = (SELECT id FROM programming_languages WHERE name = 'JavaScript') + AND plv.version = 'Node.js 22.08.0' +WHERE p.slug = 'fizz-or-buzz' + ON CONFLICT (problem_id, programming_language_version_id) DO NOTHING; + +INSERT INTO problem_setups ( + problem_id, programming_language_version_id, harness_template_id, version, initial_code, function_name, created_on, created_by_id +) +SELECT + p.id, + plv.id, + 1, + 1, + 'function solution(n: number): string { + // Your code here +} +', + 'solution', + NOW(), + NULL +FROM problems p + JOIN programming_language_versions plv + ON plv.programming_language_id = (SELECT id FROM programming_languages WHERE name = 'TypeScript') + AND plv.version = '5.6.2' +WHERE p.slug = 'fizz-or-buzz' + ON CONFLICT (problem_id, programming_language_version_id) DO NOTHING; + +INSERT INTO problem_setups ( + problem_id, programming_language_version_id, harness_template_id, version, initial_code, function_name, created_on, created_by_id +) +SELECT + p.id, + plv.id, + 2, + 1, + 'def solution(n: int) -> str: + # Your code here +', + 'solution', + NOW(), + NULL +FROM problems p + JOIN programming_language_versions plv + ON plv.programming_language_id = (SELECT id FROM programming_languages WHERE name = 'Python') + AND plv.version = '3.14.0' +WHERE p.slug = 'fizz-or-buzz' + ON CONFLICT (problem_id, programming_language_version_id) DO NOTHING; + +INSERT INTO problem_setup_test_suites (problem_setup_id, test_suite_id) +SELECT ps.id, ts.id +FROM problem_setups ps + JOIN problems p ON p.id = ps.problem_id + JOIN programming_language_versions plv ON plv.id = ps.programming_language_version_id + JOIN programming_languages pl ON pl.id = plv.programming_language_id + JOIN test_suites ts ON ts.name = 'Fizz or Buzz hidden tests' +WHERE p.slug = 'fizz-or-buzz' + AND pl.name = 'JavaScript' + AND plv.version = 'Node.js 22.08.0' ON CONFLICT (problem_setup_id, test_suite_id) DO NOTHING; \ No newline at end of file From 711e89f4665d5902360679f1ea4bb788a54fbffd Mon Sep 17 00:00:00 2001 From: admclamb Date: Tue, 12 May 2026 22:43:33 -0400 Subject: [PATCH 2/3] Update difficulty --- Database/Fixtures/dev/0002-Problems.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Database/Fixtures/dev/0002-Problems.sql b/Database/Fixtures/dev/0002-Problems.sql index 807b7e9..8482033 100644 --- a/Database/Fixtures/dev/0002-Problems.sql +++ b/Database/Fixtures/dev/0002-Problems.sql @@ -70,7 +70,7 @@ SELECT - `-10^9 <= n <= 10^9` ', - 500, + 1000, ps.id, 1, NOW(), From 286f142dac6781e5e204fc9eebea8507837873b1 Mon Sep 17 00:00:00 2001 From: admclamb Date: Wed, 13 May 2026 20:55:05 -0400 Subject: [PATCH 3/3] Update db scripts --- Database/Fixtures/dev/0002-Problems.sql | 8 +- Database/Fixtures/dev/0003-TestSuites.sql | 79 ++++++++++++++++++-- Database/Fixtures/dev/0004-ProblemSetups.sql | 11 +++ 3 files changed, 87 insertions(+), 11 deletions(-) diff --git a/Database/Fixtures/dev/0002-Problems.sql b/Database/Fixtures/dev/0002-Problems.sql index 8482033..553f052 100644 --- a/Database/Fixtures/dev/0002-Problems.sql +++ b/Database/Fixtures/dev/0002-Problems.sql @@ -44,22 +44,22 @@ SELECT gen_random_uuid(), 'Fizz or Buzz', 'fizz-or-buzz', - 'Given an integer `n`, return `"fizzbuzz"` if `n` is divisible by **both** 3 and 5, `"fizz"` if divisible by only 3, `"buzz"` if divisible by only 5, or `n` as a string if it is not divisible by 3 or 5. + 'Given an integer `n`, return `"FizzBuzz"` if `n` is divisible by **both** 3 and 5, `"Fizz"` if divisible by only 3, `"Buzz"` if divisible by only 5, or `n` as a string if it is not divisible by 3 or 5. **Example 1:** > **Input**: `n = 3` -> **Output**: `"fizz"` +> **Output**: `"Fizz"` **Example 2:** > **Input**: `n = 5` -> **Output**: `"buzz"` +> **Output**: `"Buzz"` **Example 3:** > **Input**: `n = 15` -> **Output**: `"fizzbuzz"` +> **Output**: `"FizzBuzz"` **Example 4:** diff --git a/Database/Fixtures/dev/0003-TestSuites.sql b/Database/Fixtures/dev/0003-TestSuites.sql index c95da88..3be942c 100644 --- a/Database/Fixtures/dev/0003-TestSuites.sql +++ b/Database/Fixtures/dev/0003-TestSuites.sql @@ -186,24 +186,89 @@ BEGIN RETURNING test_case_id ) INSERT INTO test_cases_expected_outputs (test_case_id, value, output_value_type_id) - SELECT tc_3.id, 'fizz', output_value_type.id FROM tc_3, output_value_type + SELECT tc_3.id, 'Fizz', output_value_type.id FROM tc_3, output_value_type UNION ALL - SELECT tc_5.id, 'buzz', output_value_type.id FROM tc_5, output_value_type + SELECT tc_5.id, 'Buzz', output_value_type.id FROM tc_5, output_value_type UNION ALL - SELECT tc_15.id, 'fizzbuzz', output_value_type.id FROM tc_15, output_value_type + SELECT tc_15.id, 'FizzBuzz', output_value_type.id FROM tc_15, output_value_type UNION ALL SELECT tc_7.id, '7', output_value_type.id FROM tc_7, output_value_type UNION ALL - SELECT tc_0.id, 'fizzbuzz', output_value_type.id FROM tc_0, output_value_type + SELECT tc_0.id, 'FizzBuzz', output_value_type.id FROM tc_0, output_value_type UNION ALL - SELECT tc_neg3.id, 'fizz', output_value_type.id FROM tc_neg3, output_value_type + SELECT tc_neg3.id, 'Fizz', output_value_type.id FROM tc_neg3, output_value_type UNION ALL - SELECT tc_neg5.id, 'buzz', output_value_type.id FROM tc_neg5, output_value_type + SELECT tc_neg5.id, 'Buzz', output_value_type.id FROM tc_neg5, output_value_type UNION ALL - SELECT tc_30.id, 'fizzbuzz', output_value_type.id FROM tc_30, output_value_type + SELECT tc_30.id, 'FizzBuzz', output_value_type.id FROM tc_30, output_value_type UNION ALL SELECT tc_2.id, '2', output_value_type.id FROM tc_2, output_value_type; END IF; END; +$$; + +DO $$ +BEGIN + IF NOT EXISTS ( + SELECT 1 FROM test_suites WHERE name = 'Fizz or Buzz public tests' + ) THEN + + WITH value_type AS ( + SELECT id FROM test_cases_inputs_value_types WHERE name = 'integer' + ), + output_value_type AS ( + SELECT id FROM test_cases_output_value_types WHERE name = 'String' + ), + suite_type_public AS ( + SELECT id FROM test_suite_types WHERE name = 'Public' + ), + public_suite AS ( + INSERT INTO test_suites (name, description, test_suite_type_id) + SELECT 'Fizz or Buzz public tests', 'Public example test cases for Fizz or Buzz', suite_type_public.id + FROM suite_type_public + RETURNING id + ), + tc_3 AS ( + INSERT INTO test_cases (test_suite_id, name, description) + SELECT public_suite.id, 'Divisible By Three', 'Input: n = 3' FROM public_suite + RETURNING id + ), + tc_5 AS ( + INSERT INTO test_cases (test_suite_id, name, description) + SELECT public_suite.id, 'Divisible By Five', 'Input: n = 5' FROM public_suite + RETURNING id + ), + tc_15 AS ( + INSERT INTO test_cases (test_suite_id, name, description) + SELECT public_suite.id, 'Divisible By Both', 'Input: n = 15' FROM public_suite + RETURNING id + ), + tc_7 AS ( + INSERT INTO test_cases (test_suite_id, name, description) + SELECT public_suite.id, 'Not Divisible', 'Input: n = 7' FROM public_suite + RETURNING id + ), + inputs AS ( + INSERT INTO test_cases_inputs (test_case_id, value, test_cases_inputs_value_type_id) + SELECT tc_3.id, '3', value_type.id FROM tc_3, value_type + UNION ALL + SELECT tc_5.id, '5', value_type.id FROM tc_5, value_type + UNION ALL + SELECT tc_15.id, '15', value_type.id FROM tc_15, value_type + UNION ALL + SELECT tc_7.id, '7', value_type.id FROM tc_7, value_type + RETURNING test_case_id + ) + INSERT INTO test_cases_expected_outputs (test_case_id, value, output_value_type_id) + SELECT tc_3.id, 'Fizz', output_value_type.id FROM tc_3, output_value_type + UNION ALL + SELECT tc_5.id, 'Buzz', output_value_type.id FROM tc_5, output_value_type + UNION ALL + SELECT tc_15.id, 'FizzBuzz', output_value_type.id FROM tc_15, output_value_type + UNION ALL + SELECT tc_7.id, '7', output_value_type.id FROM tc_7, output_value_type; + + END IF; +END; $$; \ No newline at end of file diff --git a/Database/Fixtures/dev/0004-ProblemSetups.sql b/Database/Fixtures/dev/0004-ProblemSetups.sql index 31586f8..37066c1 100644 --- a/Database/Fixtures/dev/0004-ProblemSetups.sql +++ b/Database/Fixtures/dev/0004-ProblemSetups.sql @@ -150,4 +150,15 @@ FROM problem_setups ps WHERE p.slug = 'fizz-or-buzz' AND pl.name = 'JavaScript' AND plv.version = 'Node.js 22.08.0' +ON CONFLICT (problem_setup_id, test_suite_id) DO NOTHING; + +INSERT INTO problem_setup_test_suites (problem_setup_id, test_suite_id) +SELECT ps.id, ts.id +FROM problem_setups ps + JOIN problems p ON p.id = ps.problem_id + JOIN programming_language_versions plv ON plv.id = ps.programming_language_version_id + JOIN programming_languages pl ON pl.id = plv.programming_language_id + JOIN test_suites ts ON ts.name = 'Fizz or Buzz public tests' +WHERE p.slug = 'fizz-or-buzz' + AND pl.name IN ('JavaScript', 'TypeScript', 'Python') ON CONFLICT (problem_setup_id, test_suite_id) DO NOTHING; \ No newline at end of file