-
-
Notifications
You must be signed in to change notification settings - Fork 714
Add solution for Challenge 18 by kiramux #665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughA new Go file introduces three public functions: CelsiusToFahrenheit and FahrenheitToCelsius for temperature conversion with 2-decimal rounding, plus a Round helper function for generic float rounding to specified decimal places, with example usage in main. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Possibly related PRs
Pre-merge checks✅ Passed checks (2 passed)
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. Comment |
There was a problem hiding this 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-18/submissions/kiramux/solution-template.go (2)
19-26: Remove TODO comments.The function is correctly implemented with the proper formula and 2-decimal rounding. However, the TODO comments on lines 22-23 should be removed since the implementation is complete.
Optionally, you could simplify by returning directly:
func CelsiusToFahrenheit(celsius float64) float64 { - // TODO: Implement this function - // Remember to round to 2 decimal places - f := Round(celsius * 9.0 / 5.0 + 32.0, 2) - return f + return Round(celsius*9.0/5.0+32.0, 2) }
28-35: Remove TODO comments.The function is correctly implemented with the proper formula and 2-decimal rounding. However, the TODO comments on lines 31-32 should be removed since the implementation is complete.
Optionally, you could simplify by returning directly:
func FahrenheitToCelsius(fahrenheit float64) float64 { - // TODO: Implement this function - // Remember to round to 2 decimal places - c := Round((fahrenheit - 32) * 5.0 / 9.0, 2) - return c + return Round((fahrenheit-32)*5.0/9.0, 2) }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
challenge-18/submissions/kiramux/solution-template.go(1 hunks)
🔇 Additional comments (3)
challenge-18/submissions/kiramux/solution-template.go (3)
1-6: LGTM! Clean imports.The package declaration and imports are appropriate. Both
fmtandmathare utilized in the implementation.
8-17: LGTM! Clear example usage.The main function provides clear examples of both temperature conversion directions with appropriate formatting.
37-41: LGTM! Correct rounding implementation.The Round helper function uses a standard and correct approach for rounding floats to a specified number of decimal places. It works well for the use case in this challenge (rounding to 2 decimals).
Challenge 18 Solution
Submitted by: @kiramux
Challenge: Challenge 18
Description
This PR contains my solution for Challenge 18.
Changes
challenge-18/submissions/kiramux/solution-template.goTesting
Thank you for reviewing my submission! 🚀