Skip to content

Conversation

@es-codigo
Copy link
Contributor

Challenge 1 Solution

Submitted by: @es-codigo
Challenge: Challenge 1

Description

This PR contains my solution for Challenge 1.

Changes

  • Added solution file to challenge-1/submissions/es-codigo/solution-template.go

Testing

  • Solution passes all test cases
  • Code follows Go best practices

Thank you for reviewing my submission! 🚀

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 4, 2025

Walkthrough

Adds a new Go program implementing an exported Sum(a int, b int) int and a main that reads two integers from stdin with fmt.Scanf("%d, %d"), handles scan errors, calls Sum, and prints the result.

Changes

Cohort / File(s) Summary
Challenge 1 Solution
challenge-1/submissions/es-codigo/solution-template.go
New file: defines func Sum(a int, b int) int (returns a+b); main() reads two ints via fmt.Scanf("%d, %d"), checks for scan errors, calls Sum, and prints the result.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant User as stdin
  participant Main as main()
  participant Scanf as fmt.Scanf
  participant Sum as Sum(a,b)
  participant Stdout as stdout

  rect rgb(240,248,255)
    User->>Scanf: provide input (two ints)
    Scanf-->>Main: parsed ints or error
  end

  alt scan success
    Main->>Sum: call Sum(a,b)
    Sum-->>Main: return a+b
    Main->>Stdout: print result
  else scan error
    Main->>Stdout: print error message
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Check Sum for correct addition.
  • Verify fmt.Scanf format string and error handling.
  • Confirm printed output formatting matches challenge expectations.

Possibly related PRs

Pre-merge checks

✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding a solution file for Challenge 1 by the user es-codigo, which aligns with the changeset.
Description check ✅ Passed The description is directly related to the changeset, explaining the solution submission for Challenge 1 and detailing the file added, matching the PR objectives.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 231bd24 and 5df19c8.

📒 Files selected for processing (1)
  • challenge-1/submissions/es-codigo/solution-template.go (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
challenge-1/submissions/es-codigo/solution-template.go (2)
challenge-1/submissions/Seokky/solution-template.go (1)
  • Sum (22-25)
challenge-1/submissions/MYK12397/solution-template.go (1)
  • Sum (22-25)
🔇 Additional comments (2)
challenge-1/submissions/es-codigo/solution-template.go (2)

1-5: LGTM! Clean package structure.

The package declaration and imports are appropriate for this solution.


7-19: LGTM! Good error handling.

The main function correctly reads input, handles errors appropriately, and prints the result. The input format expects comma-separated integers (e.g., "5, 3").

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
challenge-1/submissions/es-codigo/solution-template.go (2)

7-19: Logic is correct; consider the input format requirement.

The main function correctly reads input, handles errors, and prints the result. Note that fmt.Scanf("%d, %d", ...) expects exactly a comma followed by a space between the two integers (e.g., "42, 84"). If this strict format is not required by the challenge, you might consider using fmt.Scan(&a, &b) for more flexible whitespace handling.

Optionally, for more robust error handling, you could exit with a non-zero status code:

 	if err != nil {
 		fmt.Println("Error reading input:", err)
+		os.Exit(1)
-		return
 	}

Note: This would require importing the os package.


21-24: Well-implemented function with good documentation.

The Sum function is correct and includes a proper doc comment. The previous review concerns (TODO comment and spacing) have been addressed.

As an optional style improvement, Go allows grouping parameters of the same type:

-func Sum(a int, b int) int {
+func Sum(a, b int) int {
 	return a + b
 }

Both forms are valid; the shorter form is slightly more idiomatic in Go.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5df19c8 and d03c9e4.

📒 Files selected for processing (1)
  • challenge-1/submissions/es-codigo/solution-template.go (1 hunks)
🔇 Additional comments (1)
challenge-1/submissions/es-codigo/solution-template.go (1)

1-5: LGTM! Clean package structure.

The package declaration and imports are appropriate for this challenge solution.

@RezaSi RezaSi merged commit 21efc5e into RezaSi:main Nov 6, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants