feat(content): function signatures + test cases

This commit is contained in:
2025-07-13 19:53:34 +01:00
parent b434eb3a49
commit a7d29b7cce
203 changed files with 4526 additions and 0 deletions

View File

@@ -11,6 +11,28 @@ patterns:
- dfs
- union-find
function_signature: "def calc_equation(equations: list[list[str]], values: list[float], queries: list[list[str]]) -> list[float]:"
test_cases:
visible:
- input: { equations: [["a", "b"], ["b", "c"]], values: [2.0, 3.0], queries: [["a", "c"], ["b", "a"], ["a", "e"], ["a", "a"], ["x", "x"]] }
expected: [6.0, 0.5, -1.0, 1.0, -1.0]
- input: { equations: [["a", "b"], ["b", "c"], ["bc", "cd"]], values: [1.5, 2.5, 5.0], queries: [["a", "c"], ["c", "b"], ["bc", "cd"], ["cd", "bc"]] }
expected: [3.75, 0.4, 5.0, 0.2]
- input: { equations: [["a", "b"]], values: [0.5], queries: [["a", "b"], ["b", "a"], ["a", "c"], ["x", "y"]] }
expected: [0.5, 2.0, -1.0, -1.0]
hidden:
- input: { equations: [["a", "b"]], values: [2.0], queries: [["a", "a"], ["b", "b"]] }
expected: [1.0, 1.0]
- input: { equations: [], values: [], queries: [["a", "b"]] }
expected: [-1.0]
- input: { equations: [["a", "b"], ["c", "d"]], values: [2.0, 3.0], queries: [["a", "d"], ["c", "b"]] }
expected: [-1.0, -1.0]
- input: { equations: [["a", "b"], ["b", "c"], ["c", "d"]], values: [2.0, 3.0, 4.0], queries: [["a", "d"], ["d", "a"]] }
expected: [24.0, 0.041666666666666664]
- input: { equations: [["x", "y"]], values: [1.0], queries: [["x", "y"], ["y", "x"]] }
expected: [1.0, 1.0]
description: |
You are given an array of variable pairs `equations` and an array of real numbers `values`, where `equations[i] = [A_i, B_i]` and `values[i]` represent the equation `A_i / B_i = values[i]`. Each `A_i` or `B_i` is a string that represents a single variable.