-
-
Notifications
You must be signed in to change notification settings - Fork 713
Add solution for Challenge 18 by Be1chenok #578
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
Add solution for Challenge 18 by Be1chenok #578
Conversation
WalkthroughAdds a new Go source file with three exported functions for temperature conversion and rounding, plus a main function demonstrating usage. Functions perform direct arithmetic conversions between Celsius and Fahrenheit and round float values to a specified number of decimals. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant Main as main()
participant Conv as Conversion funcs
User->>Main: Run program
Main->>Conv: CelsiusToFahrenheit(c)
Conv-->>Main: fahrenheit
Main->>Conv: FahrenheitToCelsius(f)
Conv-->>Main: celsius
Main->>Conv: Round(value, decimals)
Conv-->>Main: rounded
Main-->>User: Print results
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 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: 0
🧹 Nitpick comments (1)
challenge-18/submissions/Be1chenok/solution-template.go (1)
37-41: LGTM! Round function works correctly for the current use case.The rounding implementation using
math.Pow10andmath.Roundis appropriate and produces accurate results.Consider adding input validation for the
decimalsparameter to handle edge cases more gracefully, though this is not critical since the function is currently only called withdecimals=2: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/Be1chenok/solution-template.go(1 hunks)
🔇 Additional comments (4)
challenge-18/submissions/Be1chenok/solution-template.go (4)
8-12: LGTM! Constants are correctly defined.The conversion multipliers and temperature offset are mathematically accurate for the temperature conversion formulas.
14-23: LGTM! Clear demonstration of the conversion functions.The example usage effectively demonstrates both temperature conversion functions with readable output.
25-29: LGTM! Celsius to Fahrenheit conversion is correctly implemented.The formula
F = C × 9/5 + 32is accurately applied, and rounding to 2 decimal places provides appropriate precision for temperature values.
31-35: LGTM! Fahrenheit to Celsius conversion is correctly implemented.The formula
C = (F - 32) × 5/9is accurately applied with appropriate rounding.
Challenge 18 Solution
Submitted by: @Be1chenok
Challenge: Challenge 18
Description
This PR contains my solution for Challenge 18.
Changes
challenge-18/submissions/Be1chenok/solution-template.goTesting
Thank you for reviewing my submission! 🚀