fix(S5-03): 改型卡的累加例子改成真的输出负数,并绑上护栏 - #67
Merged
Merged
Conversation
任务 2 的改型卡拿一个累加例子讲 int 回绕,题面写的是「手算总和是正数, 程序却输出负数」。两个历史版本的数字本机 g++ 实测都回绕成正数: - 「累加 1 到 100000 再乘系数 100000」-> +2087268864 - 「n=100000,每项 10^5」-> +1410065408 孩子照着跑看不到任何负数,会以为「没有溢出」。同一个说法还出现在三步对照卡 与脚手架注释里。 例子改成 n=100000、每项 80000:手算总和 8000000000(80 亿,正数),int 实测 输出 -589934592,真的回绕成负数;80 亿同时超过 unsigned int 上限 4294967295, 所以检查器里「unsigned int 还是装不下」那条指正依旧成立。讲义、三步卡、脚手架 注释、检查指正与提示文案统一成同一组数字。 新增 tests/s5-03-accumulate-overflow-example.test.ts 把例子绑到 int32 回绕计算: 题面写的输出必须等于回绕结果且为负、手算总和必须是项数乘以每项、必须同时超过 int 与 unsigned int 上限,旧说法(10^10 量级、乘系数)不得再出现。证据记进 docs/review/question-verification.json 的 findings。 验证:bun test 783 pass / 0 fail(含新增 6 项);CSP_E2E_LESSONS=s5-03 跑 s2-typed-cdp.ts 17/17、flow-cdp.ts 19/19、keyboard-cdp.ts 8/8,真机浏览器里 检查器指正与渐进提示已是新的 80 亿量级说法。 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题(可证伪的事实错误)
lessons/s5-03任务 2 的改型卡用一个累加例子讲int回绕,题面写「手算总和是正数,程序却输出负数」。两个历史版本的数字本机g++实测都回绕成正数:int输出孩子照着跑看不到负数,会得出「没有溢出」的相反结论——正好把本课要防的坑教反。同一个说法还散在三步对照卡和脚手架注释里。
修法
改成
n=100000、每项80000:手算总和8000000000(80 亿,正数),int实测输出-589934592,真的回绕成负数;80 亿同时超过unsigned int上限4294967295,所以检查器里「unsigned int 还是装不下」那条指正依旧成立。讲义、三步卡、脚手架注释、检查指正、渐进提示统一成同一组数字。TDD
先写
tests/s5-03-accumulate-overflow-example.test.ts并确认失败(当时页面里找不到可机检的场景行),再改页面到绿。护栏把例子绑到 int32 回绕计算:INT32_MAX与UINT32_MAX10^10量级、乘系数)不得再出现改数字而不重新验证,这个测试会红。
验证证据
bun test:783 pass / 0 fail(64 文件;修复前 777,新增 6 项)CSP_E2E_LESSONS=s5-03):s2-typed-cdp.ts17/17、flow-cdp.ts19/19、keyboard-cdp.ts8/8;输出里检查器指正与提示已是新的 80 亿量级说法docs/review/question-verification.json的findings,并在tests/e2e/s5-03-manual-checklist.md补了本轮复验行边界
只改事实错误与护栏,未动课程结构、题库、
lesson.json、验收矩阵;不涉及在线判题、账号、视频资产或 Node 工具链。