Skip to content

Conversation

@forever-free1
Copy link
Contributor

Challenge 18 Solution

Submitted by: @forever-free1
Challenge: Challenge 18

Description

This PR contains my solution for Challenge 18.

Changes

  • Added solution file to challenge-18/submissions/forever-free1/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 13, 2025

Walkthrough

A new Go solution file is added to challenge-18/submissions/forever-free1/ that implements temperature conversion utilities, including CelsiusToFahrenheit, FahrenheitToCelsius, and a Round helper function for numeric precision.

Changes

Cohort / File(s) Summary
Temperature Conversion Utility
challenge-18/submissions/forever-free1/solution-template.go
Added three exported functions: CelsiusToFahrenheit() and FahrenheitToCelsius() for temperature unit conversion, and Round() for formatting floating-point values to a specified decimal precision. Includes a main function demonstrating example conversions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Straightforward utility functions — Three functions implementing standard temperature conversion formulas and basic rounding logic with no complex control flow.
  • No interdependencies — Functions are self-contained utilities with no interactions with other modules.
  • New file addition — Single-file addition with no modifications to existing code, reducing integration complexity.

Possibly related PRs

  • PR #651: Adds identical temperature conversion functions (CelsiusToFahrenheit, FahrenheitToCelsius, Round) in a separate solution submission file.
  • PR #633: Implements the same temperature-conversion utilities across different challenge-18 submission folders.
  • PR #610: Introduces matching temperature-conversion function signatures and rounding logic in a related challenge submission.

Pre-merge checks

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.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 clearly identifies that this PR adds a solution for Challenge 18 submitted by forever-free1, which directly matches the changeset content.
Description check ✅ Passed The description is directly related to the changeset, explaining the Challenge 18 solution submission and the file added, with appropriate testing confirmations.

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 (2)
challenge-18/submissions/forever-free1/solution-template.go (2)

20-23: Add documentation comment and improve formatting.

The function is missing a documentation comment (unlike FahrenheitToCelsius). Also, consider whether hardcoding the rounding to 2 decimal places is necessary, since the main function already formats output with %.2f.

Apply this diff to add documentation and improve formatting:

+// CelsiusToFahrenheit converts a temperature from Celsius to Fahrenheit +// Formula: F = C × 9/5 + 32 func CelsiusToFahrenheit(celsius float64) float64 { - f:= celsius*9/5 + 32 - return Round(f,2) +f := celsius*9/5 + 32 +return Round(f, 2) }

Alternatively, consider returning the unrounded value and letting callers control precision:

+// CelsiusToFahrenheit converts a temperature from Celsius to Fahrenheit +// Formula: F = C × 9/5 + 32 func CelsiusToFahrenheit(celsius float64) float64 { - f:= celsius*9/5 + 32 - return Round(f,2) +return celsius*9/5 + 32 }

27-30: Improve formatting and consider precision flexibility.

Minor formatting improvements needed for Go conventions. Also, similar to CelsiusToFahrenheit, consider whether hardcoding rounding to 2 decimal places is necessary.

Apply this diff to improve formatting:

 func FahrenheitToCelsius(fahrenheit float64) float64 { - c := (fahrenheit-32) * 5/9 -return Round(c,2) +c := (fahrenheit - 32) * 5/9 +return Round(c, 2) }

Or, for maximum flexibility, return the unrounded value:

 func FahrenheitToCelsius(fahrenheit float64) float64 { - c := (fahrenheit-32) * 5/9 -return Round(c,2) +return (fahrenheit - 32) * 5/9 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 14d1f5f and 6817244.

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

32-36: LGTM!

The Round function is well-documented and correctly implemented using standard library functions.

@RezaSi RezaSi merged commit 898d751 into RezaSi:main Nov 13, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants