Code Snippets Go

L3
ModelContextProtocolNotionComputer Science Student Dashboard

Add a new Go column to the Code Snippets section between Python and JavaScript columns.

Created by Zijian Wu
2025-07-27
Content OrganizationVisual FormattingTemplate Population

Model Ranking

Click on the dots to view the trajectory of each task run
Model
Run Results
Pass@4
Pass^4
Avg Time
Avg Turns
Input Tokens
Output Tokens
Total Tokens
Claude
claude-sonnet-4-low
4
/4
107.4s
12.8
509,322
2,585
511,907
OpenAI
gpt-5-high
4
/4
487.9s
10.8
113,727
20,391
134,118
OpenAI
gpt-5-low
4
/4
181.8s
10.0
99,718
9,866
109,584
OpenAI
gpt-5-medium
4
/4
226.8s
10.8
112,764
11,583
124,348
OpenAI
gpt-5-mini-high
4
/4
112.0s
9.8
93,368
9,320
102,689
OpenAI
gpt-5-mini-medium
4
/4
72.5s
10.5
108,699
5,150
113,848
OpenAI
o3
4
/4
83.9s
10.8
98,342
4,275
102,617
Claude
claude-sonnet-4
3
/4
120.2s
14.0
235,217
2,876
238,093
DeepSeek
deepseek-chat
3
/4
161.1s
14.5
229,656
1,634
231,290
Z.ai
glm-4-5
3
/4
261.5s
34.3
911,315
6,492
917,807
Qwen
qwen-3-max
3
/4
228.3s
35.3
1,258,162
2,713
1,260,875
Claude
claude-sonnet-4-high
2
/4
182.9s
20.5
971,224
4,125
975,349
OpenAI
gpt-5-mini-low
2
/4
43.7s
7.8
81,543
2,772
84,315
OpenAI
o4-mini
2
/4
149.4s
8.3
70,799
10,728
81,527
Claude
claude-opus-4-1
1
/1
--
244.8s
11.0
169,301
3,924
173,225
Gemini
gemini-2-5-flash
1
/4
48.3s
5.5
298,918
5,280
304,197
OpenAI
gpt-oss-120b
1
/4
27.2s
5.8
60,049
1,495
61,544
MoonshotAI
kimi-k2-0711
1
/4
71.8s
11.0
137,609
1,629
139,238
Qwen
qwen-3-coder-plus
1
/4
63.8s
15.5
283,213
1,987
285,200
Gemini
gemini-2-5-pro
0
/4
105.9s
4.8
40,339
6,386
46,725
OpenAI
gpt-4-1
0
/4
43.7s
11.0
94,685
1,099
95,784
OpenAI
gpt-4-1-mini
0
/4
51.9s
7.8
61,395
947
62,341
OpenAI
gpt-4-1-nano
0
/4
29.4s
12.3
70,608
692
71,300
OpenAI
gpt-5-nano-high
0
/4
392.8s
9.8
98,773
86,903
185,676
OpenAI
gpt-5-nano-low
0
/4
63.0s
4.8
28,515
10,907
39,422
OpenAI
gpt-5-nano-medium
0
/4
173.5s
7.8
62,720
33,687
96,408
Grok
grok-4
0
/4
311.7s
18.3
384,952
10,768
395,720
Grok
grok-code-fast-1
0
/4
283.3s
22.8
559,227
6,828
576,291
MoonshotAI
kimi-k2-0905
0
/4
427.1s
36.3
710,176
4,691
714,867

Task State

Notion Workspace
This task is executed based on this Notion workspace
This workspace is cloned from notion official template marketplace.View Original Template

Instruction

Find the page named "Computer Science Student Dashboard" and add a new Go column to the "Code Snippets" section.

Task Requirements:

  1. In the "Code Snippets" section, create (or locate) a column dedicated to the Go programming language. This column must appear between the existing Python and JavaScript columns within the same column list.
  2. At the top of the Go column, add a bold paragraph that contains exactly the text Go.
  3. Under the header paragraph, add three code-block blocks configured with language set to go: a. Basic Go program – Caption must be Basic Go program and the code content must be exactly:
    Go
    package main
    
    import "fmt"
    
    func main() {
        fmt.Println("Hello, World!")
    }
    b. For loop in Go – Caption must be For loop in Go and the code content must be exactly:
    Go
    for i := 0; i < 5; i++ {
        fmt.Println(i)
    }
    c. Function definition in Go – Caption must be Function definition in Go and the code content must be exactly:
    Go
    func add(a, b int) int {
        return a + b
    }


Verify

*.py
Python
import sys
from notion_client import Client
from tasks.utils import notion_utils

# Expected code blocks (language=go)
EXPECTED_CODE_BLOCKS = [
    {
        "caption": "Basic Go program",
        "code": (
            'package main\n\nimport "fmt"\n\nfunc main() {\n    fmt.Println("Hello, World!")\n}'
        ),
    },
    {
        "caption": "For loop in Go",
        "code": ("for i := 0; i < 5; i++ {\n    fmt.Println(i)\n}"),
    },
    {
        "caption": "Function definition in Go",
        "code": ("func add(a, b int) int {\n    return a + b\n}"),
    },
]

HEADER_TEXT = "Go"


def _normalize(text: str) -> str:
    """Remove trailing spaces on each line and strip leading/trailing blank lines."""
    return "\n".join(line.rstrip() for line in text.strip().splitlines())


def _find_page(notion: Client, main_id: str | None) -> str | None:
    """Return a page_id to verify against or None if not found."""
    page_id = None
    if main_id:
        found_id, object_type = notion_utils.find_page_or_database_by_id(
            notion, main_id
        )
        if found_id and object_type == "page":
            page_id = found_id
    if not page_id:
        page_id = notion_utils.find_page(notion, "Computer Science Student Dashboard")
    return page_id


def _has_bold_header_text(block, text: str) -> bool:
    """Generic bold header/paragraph check for a given text."""
    block_type = block.get("type")
    if block_type not in {"paragraph", "heading_1", "heading_2", "heading_3"}:
        return False
    rich_text_list = block.get(block_type, {}).get("rich_text", [])
    if not rich_text_list:
        return False
    plain = "".join(rt.get("plain_text", "") for rt in rich_text_list).strip()
    if plain != text:
        return False
    return any(rt.get("annotations", {}).get("bold", False) for rt in rich_text_list)


def _go_column_order_correct(notion: Client, page_id: str) -> bool:
    """Return True if there exists a column list where Python → Go → JavaScript order holds."""
    # Gather all blocks once (flat list) to locate column_list blocks
    all_blocks = notion_utils.get_all_blocks_recursively(notion, page_id)
    column_list_ids = [
        blk["id"] for blk in all_blocks if blk.get("type") == "column_list"
    ]

    for cl_id in column_list_ids:
        # Retrieve columns in explicit order
        columns = notion.blocks.children.list(block_id=cl_id).get("results", [])
        header_to_idx: dict[str, int] = {}
        for idx, col in enumerate(columns):
            # Recursively inspect blocks within this column
            col_blocks = notion_utils.get_all_blocks_recursively(notion, col["id"])
            for blk in col_blocks:
                if _has_bold_header_text(blk, "Python"):
                    header_to_idx.setdefault("Python", idx)
                elif _has_bold_header_text(blk, "Go"):
                    header_to_idx.setdefault("Go", idx)
                elif _has_bold_header_text(blk, "JavaScript"):
                    header_to_idx.setdefault("JavaScript", idx)
            # Short-circuit if all three found within current traversal
            if len(header_to_idx) == 3:
                break

        if (
            "Python" in header_to_idx
            and "Go" in header_to_idx
            and "JavaScript" in header_to_idx
            and header_to_idx["Python"]
            < header_to_idx["Go"]
            < header_to_idx["JavaScript"]
        ):
            return True
    return False


def _collect_code_blocks(blocks):
    """Return list of (code_content, caption) tuples for code blocks with language 'go'."""
    collected = []
    for block in blocks:
        if block.get("type") != "code":
            continue
        code_data = block.get("code", {})
        if code_data.get("language") != "go":
            continue
        code_plain = "".join(
            rt.get("plain_text", "") for rt in code_data.get("rich_text", [])
        )
        caption_plain = "".join(
            rt.get("plain_text", "") for rt in code_data.get("caption", [])
        )
        collected.append((code_plain, caption_plain))
    return collected


def verify(notion: Client, main_id: str | None = None) -> bool:
    page_id = _find_page(notion, main_id)
    if not page_id:
        print("Error: Target page not found.", file=sys.stderr)
        return False

    all_blocks = notion_utils.get_all_blocks_recursively(notion, page_id)

    # Verify header
    header_ok = any(_has_bold_header_text(b, HEADER_TEXT) for b in all_blocks)
    if not header_ok:
        print("Failure: Bold header 'Go' not found.", file=sys.stderr)
        return False

    # Verify code blocks
    code_blocks_found = _collect_code_blocks(all_blocks)

    remaining = EXPECTED_CODE_BLOCKS.copy()
    for code, caption in code_blocks_found:
        norm_code = _normalize(code)
        for expected in remaining:
            if (
                _normalize(expected["code"]) == norm_code
                and expected["caption"] == caption
            ):
                remaining.remove(expected)
                break
    if remaining:
        missing = ", ".join(exp["caption"] for exp in remaining)
        print(
            f"Failure: Missing or incorrect Go code blocks: {missing}", file=sys.stderr
        )
        return False

    # Verify column order Python → Go → JavaScript
    if not _go_column_order_correct(notion, page_id):
        print(
            "Failure: Go column is not positioned between Python and JavaScript.",
            file=sys.stderr,
        )
        return False

    print(
        "Success: Verified Go column with required code blocks and correct positioning."
    )
    return True


def main():
    notion = notion_utils.get_notion_client()
    main_id = sys.argv[1] if len(sys.argv) > 1 else None
    sys.exit(0 if verify(notion, main_id) else 1)


if __name__ == "__main__":
    main()