Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

roman-numerals/solution.go: 4 prints IIII and 1994 prints MDCCCCLXXXXIIII (no subtractive forms)

已关闭
#25 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

已经有一个关联 PR 被合并了。

  • #28 来自 @tanujb03 —— 已关闭,未合并
  • #34 来自 @VatsalRaina01 —— 已合并

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
go, python
领域
cli

调研方向

The bug is in problems/roman-numerals/solution.go, which emits additive forms like IIII and VIIII; problems/roman-numerals/solution.py already gives MCMXCIV for 1994 and is a reference. Add the subtractive inputs (3, 8, 2026, 1500, 3888) to cases.txt and run python3 run.py roman-numerals. Done means the Go output matches the README examples. Two open pull requests (#28, #34) already target this, so check them before starting.

由索引模型根据 Issue 内容生成。

描述

bug good first issue

What I did

  1. Fresh checkout of main, Go installed.
  2. Run the Go solution on the README's own examples:
echo 4    | go run problems/roman-numerals/solution.go
echo 9    | go run problems/roman-numerals/solution.go
echo 40   | go run problems/roman-numerals/solution.go
echo 1994 | go run problems/roman-numerals/solution.go
echo 3999 | go run problems/roman-numerals/solution.go
  1. For comparison, the Python solution on the same inputs:
echo 1994 | python3 problems/roman-numerals/solution.py

What I expected
The problem README says: "Use the subtractive forms: 4 is IV, 9 is IX, 40 is XL, 90 is XC, 400 is CD and 900 is CM. So 1994 is MCMXCIV." (problems/roman-numerals/README.md)

So IV, IX, XL, MCMXCIV and MMMCMXCIX.

What happened instead

4    -> IIII
9    -> VIIII
40   -> XXXX
1994 -> MDCCCCLXXXXIIII
3999 -> MMMDCCCCLXXXXVIIII

The Python solution prints MCMXCIV for 1994. The Go solution is wrong for 1952 of the numbers from 1 to 3999. python3 run.py roman-numerals passes today only because cases.txt does not include any input that needs a subtractive form (3, 8, 2026, 1500, 3888).

Environment
code-corner main @ 81bb5dc, Go 1.27, Windows 11.

I'd like to work on the fix for this, and add the failing inputs to cases.txt as the Contributing section asks.

主要语言
Python
星标
1
派生
6
平均合并
17 小时 52 分钟
30 天内合并 PR
14

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

techcsispit/code-corner 的其他 Issue

查看 techcsispit/code-corner 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。