-
-
Notifications
You must be signed in to change notification settings - Fork 713
Add solution for Challenge 18 by AlexO-85 #691
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
WalkthroughIntroduces a new Go program with temperature conversion utilities. Implements CelsiusToFahrenheit and FahrenheitToCelsius functions that perform bidirectional temperature conversions and return results rounded to two decimal places. Includes a Round helper function for consistent decimal precision across conversions. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Possibly related PRs
Pre-merge checks❌ Failed checks (1 warning)
✅ 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: 3
🧹 Nitpick comments (1)
challenge-18/submissions/AlexO-85/solution-template.go (1)
36-39: Consider validating the decimals parameter.The Round function doesn't validate that
decimalsis non-negative. While negative values would technically work withmath.Pow10, they might produce unexpected behavior. Consider adding a check if this function will be used more broadly.Example validation:
func Round(value float64, decimals int) float64 { if decimals < 0 { decimals = 0 } precision := math.Pow10(decimals) return math.Round(value*precision) / precision }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
challenge-18/submissions/AlexO-85/solution-template.go(1 hunks)
🔇 Additional comments (2)
challenge-18/submissions/AlexO-85/solution-template.go (2)
1-6: LGTM!Package declaration and imports are appropriate for the temperature conversion utilities.
8-17: LGTM!The example usage clearly demonstrates both conversion functions with well-formatted output.
| // TODO: Implement this function | ||
| // Remember to round to 2 decimal places |
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.
Remove leftover TODO comments.
The function is already implemented correctly, so these TODO comments from the template should be removed.
Apply this diff:
- // TODO: Implement this function
- // Remember to round to 2 decimal places
return Round(celsius*9.0/5.0 + 32.0, 2)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // TODO: Implement this function | |
| // Remember to round to 2 decimal places | |
| return Round(celsius*9.0/5.0 + 32.0, 2) |
🤖 Prompt for AI Agents
In challenge-18/submissions/AlexO-85/solution-template.go around lines 22 to 23,
remove the leftover TODO comment lines ("// TODO: Implement this function" and
"// Remember to round to 2 decimal places") since the function is already
implemented; simply delete those two comment lines to clean up the file.
| // TODO: Implement this function | ||
| // Remember to round to 2 decimal places |
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.
Remove leftover TODO comments.
The function is already implemented correctly, so these TODO comments from the template should be removed.
Apply this diff:
- // TODO: Implement this function
- // Remember to round to 2 decimal places
return Round((fahrenheit - 32.0) * 5.0 / 9.0, 2)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // TODO: Implement this function | |
| // Remember to round to 2 decimal places | |
| return Round((fahrenheit - 32.0) * 5.0 / 9.0, 2) |
🤖 Prompt for AI Agents
In challenge-18/submissions/AlexO-85/solution-template.go around lines 30 to 31,
remove the leftover TODO comment lines ("// TODO: Implement this function" and
"// Remember to round to 2 decimal places") because the function is already
implemented; simply delete those two comment lines so the file no longer
contains stale template TODOs.
| // Round rounds a float64 value to the specified number of decimal places | ||
| func Round(value float64, decimals int) float64 { |
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.
Add documentation comment for exported function.
Go best practices require documentation comments for all exported identifiers. The Round function needs a documentation comment explaining its purpose and parameters.
Apply this diff:
-// Round rounds a float64 value to the specified number of decimal places
+// Round rounds a float64 value to the specified number of decimal places.
+// For example, Round(3.14159, 2) returns 3.14.
func Round(value float64, decimals int) float64 {📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // Round rounds a float64 value to the specified number of decimal places | |
| func Round(value float64, decimals int) float64 { | |
| // Round rounds a float64 value to the specified number of decimal places. | |
| // For example, Round(3.14159, 2) returns 3.14. | |
| func Round(value float64, decimals int) float64 { |
🤖 Prompt for AI Agents
In challenge-18/submissions/AlexO-85/solution-template.go around lines 35 to 36,
the exported Round function lacks a Go documentation comment; add a doc comment
immediately above the function starting with "Round" that briefly describes what
the function does, its parameters (value float64, decimals int) and what it
returns (rounded float64), e.g. one or two concise sentences following Go doc
conventions.
Challenge 18 Solution
Submitted by: @AlexO-85
Challenge: Challenge 18
Description
This PR contains my solution for Challenge 18.
Changes
challenge-18/submissions/AlexO-85/solution-template.goTesting
Thank you for reviewing my submission! 🚀