Skip to content

Conversation

@Johrespi
Copy link
Contributor

Challenge 18 Solution

Submitted by: @Johrespi
Challenge: Challenge 18

Description

This PR contains my solution for Challenge 18.

Changes

  • Added solution file to challenge-18/submissions/Johrespi/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 Oct 31, 2025

Walkthrough

This change introduces a new Go program implementing temperature conversion utilities in a submission file. It includes CelsiusToFahrenheit and FahrenheitToCelsius conversion functions, a Round helper for decimal precision, and a main function demonstrating their usage with print statements.

Changes

Cohort / File(s) Change Summary
Temperature Conversion Utilities
challenge-18/submissions/Johrespi/solution-template.go
Added CelsiusToFahrenheit and FahrenheitToCelsius functions performing temperature conversions with 2-decimal rounding, a Round helper function for formatting float values, and a main function demonstrating both conversions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify mathematical correctness of conversion formulas (F = C × 9/5 + 32 and C = (F − 32) × 5/9)
  • Check that Round function correctly uses math.Round with power-of-10 scaling
  • Confirm rounding to 2 decimal places is consistently applied

Possibly related PRs

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 title "Add solution for Challenge 18 by Johrespi" is directly related to the main change in the pull request. The changeset introduces a Go solution file that implements temperature conversion functions for Challenge 18, and the title accurately captures that a solution is being added. The title is concise, clear, and specific enough for a teammate scanning the repository history to understand that this is a challenge solution submission. While it doesn't describe the specific implementation details (like temperature conversion functions), it appropriately highlights the primary change from a high level, which is appropriate for a PR title.
Description Check ✅ Passed The pull request description is clearly related to the changeset. It explains that this is a solution submission for Challenge 18, identifies the submitter, specifies the file path where the solution was added, and includes a testing checklist confirming the solution passes all test cases and follows Go best practices. The description provides appropriate context and is directly relevant to the changes being made, meeting the lenient criteria that the description need only be related in some way 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
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/Johrespi/solution-template.go (2)

19-25: Remove obsolete TODO comments and consider simplifying type conversions.

The implementation is correct, but the TODO comments should be removed since the function is now complete. Additionally, the explicit float64() conversions can be simplified by using float literals.

Apply this diff to clean up the code:

 // CelsiusToFahrenheit converts a temperature from Celsius to Fahrenheit
 // Formula: F = C × 9/5 + 32
 func CelsiusToFahrenheit(celsius float64) float64 {
-	// TODO: Implement this function
-	// Remember to round to 2 decimal places
-	return Round(celsius * (float64(9) / float64(5)) + float64(32), 2) 
+	return Round(celsius*9.0/5.0+32, 2)
 }

27-33: Remove obsolete TODO comments and consider simplifying type conversions.

The implementation is correct, but the TODO comments should be removed since the function is now complete. Additionally, the explicit float64() conversions can be simplified by using float literals.

Apply this diff to clean up the code:

 // FahrenheitToCelsius converts a temperature from Fahrenheit to Celsius
 // Formula: C = (F - 32) × 5/9
 func FahrenheitToCelsius(fahrenheit float64) float64 {
-	// TODO: Implement this function
-	// Remember to round to 2 decimal places
-	return Round((fahrenheit - float64(32)) * float64(5) / float64(9), 2) 
+	return Round((fahrenheit-32)*5.0/9.0, 2)
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9726d4c and b6275ba.

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

8-17: LGTM!

The example usage clearly demonstrates both conversion functions with appropriate test values.


35-39: LGTM!

The rounding implementation is clean and correct, using the appropriate math package functions.

@RezaSi RezaSi merged commit 527f556 into RezaSi:main Oct 31, 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants