Skip to content

Conversation

@k4sper1love
Copy link
Contributor

Challenge 18 Solution

Submitted by: @k4sper1love
Challenge: Challenge 18

Description

This PR contains my solution for Challenge 18.

Changes

  • Added solution file to challenge-18/submissions/k4sper1love/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 16, 2025

Walkthrough

Adds a new Go solution file containing three exported functions: CelsiusToFahrenheit and FahrenheitToCelsius for temperature unit conversion using standard formulas, and a Round helper function for decimal rounding. Includes a main function demonstrating the conversions.

Changes

Cohort / File(s) Summary
Temperature conversion solution
challenge-18/submissions/k4sper1love/solution-template.go
Added three exported functions for Celsius-to-Fahrenheit and Fahrenheit-to-Celsius conversion using standard arithmetic formulas, with a Round helper for decimal precision; includes main demonstrating usage

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

  • Single file addition with straightforward arithmetic conversion formulas
  • No complex logic or edge case handling beyond standard float operations
  • Verify conversion formulas (F = C × 9/5 + 32 and inverse) are correctly implemented
  • Confirm Round function achieves intended decimal precision using power-of-ten scaling

Possibly related PRs

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding a Challenge 18 solution submission by a particular user, which aligns with the actual changeset.
Description check ✅ Passed The description is directly related to the changeset, providing context about the Challenge 18 solution submission, the file added, and testing assertions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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 (1)
challenge-18/submissions/k4sper1love/solution-template.go (1)

33-37: Consider optional refinements for the Round helper.

The rounding logic is correct and works well for the temperature conversion use cases. Two optional suggestions:

  1. Input validation: The function doesn't handle edge cases like negative decimals values, which would produce unexpected results. For a more robust implementation, consider adding validation.

  2. Function visibility: Since Round is exported (capitalized), it becomes part of the public API. If it's only intended as a helper for the conversion functions, consider making it private (lowercase round).

Both suggestions are optional refinements that don't affect the correctness of the current implementation.

If you'd like to add validation, here's an example:

 // Round rounds a float64 value to the specified number of decimal places
 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 9b711a4 and 729214d.

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

8-17: LGTM! Clean demonstration of the conversion functions.

The example usage clearly demonstrates both conversion functions with proper formatting.


19-24: LGTM! Correct temperature conversion formula.

The Celsius to Fahrenheit conversion is implemented correctly using the standard formula F = C × 9/5 + 32, with appropriate rounding.


26-31: LGTM! Correct temperature conversion formula.

The Fahrenheit to Celsius conversion is implemented correctly using the standard formula C = (F - 32) × 5/9, with appropriate rounding.

@RezaSi RezaSi merged commit 1b091e5 into RezaSi:main Nov 18, 2025
5 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Nov 18, 2025
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