Skip to content

Conversation

Be1chenok
Copy link

Challenge 18 Solution

Submitted by: @Be1chenok
Challenge: Challenge 18

Description

This PR contains my solution for Challenge 18.

Changes

  • Added solution file to challenge-18/submissions/Be1chenok/solution-template.go

Testing

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

Thank you for reviewing my submission! 🚀

Copy link

coderabbitai bot commented Oct 12, 2025

Walkthrough

Adds 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

Cohort / File(s) Change summary
Temperature conversion utilities
challenge-18/submissions/Be1chenok/solution-template.go
Added CelsiusToFahrenheit, FahrenheitToCelsius, and Round functions; defined constants for conversion factors; included a main function with example calls.

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
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

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 pull request title succinctly describes the primary change by indicating that a solution is being added for Challenge 18 by the named contributor, making it clear and directly related to the content of the changeset without extraneous detail.
Description Check ✅ Passed The pull request description clearly outlines the purpose of the changes, specifies the added file, confirms that all tests pass, and notes adherence to Go best practices, demonstrating full relevance to the changeset.

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

@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/Be1chenok/solution-template.go (1)

37-41: LGTM! Round function works correctly for the current use case.

The rounding implementation using math.Pow10 and math.Round is appropriate and produces accurate results.

Consider adding input validation for the decimals parameter to handle edge cases more gracefully, though this is not critical since the function is currently only called with decimals=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

📥 Commits

Reviewing files that changed from the base of the PR and between a2868df and ac38302.

📒 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 + 32 is 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/9 is accurately applied with appropriate rounding.

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