Skip to content

Conversation

@yz4230
Copy link
Contributor

@yz4230 yz4230 commented Nov 19, 2025

Challenge 18 Solution

Submitted by: @yz4230
Challenge: Challenge 18

Description

This PR contains my solution for Challenge 18.

Changes

  • Added solution file to challenge-18/submissions/yz4230/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 19, 2025

Walkthrough

A new Go program is added in challenge-18/submissions/yz4230/solution-template.go that implements temperature conversion utilities with functions for converting between Celsius and Fahrenheit, a rounding helper, and a main function demonstrating the conversions.

Changes

Cohort / File(s) Change Summary
Temperature Conversion Utilities
challenge-18/submissions/yz4230/solution-template.go
Adds four functions: CelsiusToFahrenheit() and FahrenheitToCelsius() for bidirectional temperature conversion, Round() helper for numerical precision, and main() for demonstrating usage with example conversions. Imports fmt and math packages.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Review the conversion formulas (F = C×9/5 + 32 and inverse) for correctness
  • Verify the Round() function implementation for proper decimal precision handling
  • Confirm the main() demonstration is syntactically correct and produces expected output formatting

Possibly related PRs

Pre-merge checks

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding a solution for Challenge 18 by a specific contributor (yz4230).
Description check ✅ Passed The description is directly related to the changeset, clearly explaining the Challenge 18 solution submission with relevant details about the contribution.

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: 0

🧹 Nitpick comments (1)
challenge-18/submissions/yz4230/solution-template.go (1)

19-31: LGTM! Temperature conversion formulas are correct.

Both conversion functions implement the correct formulas and properly round to 2 decimal places. The logic is sound and follows the requirements.

Optional: Simplify parentheses on line 23.

The extra parentheses around celsius*9/5+32 are not necessary and could be removed for cleaner code:

-	return Round((celsius*9/5+32), 2)
+	return Round(celsius*9/5+32, 2)

Note: Line 30's parentheses are correct as-is, since (fahrenheit-32) must be evaluated before multiplication.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ca8ea29 and f2a2adb.

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

1-6: LGTM! Appropriate imports for temperature conversion utilities.

The package declaration and imports are correct. Using standard library packages fmt and math is appropriate for this temperature conversion implementation.


8-17: LGTM! Main function demonstrates the conversions clearly.

The example usage properly demonstrates both temperature conversion functions with appropriate formatting.


33-37: LGTM! Rounding implementation is correct.

The Round function uses a standard approach: scale up by 10^decimals, apply math.Round, then scale back down. This correctly rounds float values to the specified number of decimal places.

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.

1 participant