Skip to content

Conversation

@kiramux
Copy link
Contributor

@kiramux kiramux commented Nov 4, 2025

Challenge 18 Solution

Submitted by: @kiramux
Challenge: Challenge 18

Description

This PR contains my solution for Challenge 18.

Changes

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

Walkthrough

A new Go file introduces three public functions: CelsiusToFahrenheit and FahrenheitToCelsius for temperature conversion with 2-decimal rounding, plus a Round helper function for generic float rounding to specified decimal places, with example usage in main.

Changes

Cohort / File(s) Summary
Temperature conversion utility
challenge-18/submissions/kiramux/solution-template.go
Adds CelsiusToFahrenheit, FahrenheitToCelsius, and Round functions implementing temperature conversion logic with decimal rounding via math operations. Includes main function with example usage.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related PRs

Pre-merge checks

✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding a solution file for Challenge 18 by kiramux.
Description check ✅ Passed The description is directly related to the changeset, clearly explaining that it adds a solution for Challenge 18 in the specified file path.

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/kiramux/solution-template.go (2)

19-26: Remove TODO comments.

The function is correctly implemented with the proper formula and 2-decimal rounding. However, the TODO comments on lines 22-23 should be removed since the implementation is complete.

Optionally, you could simplify by returning directly:

 func CelsiusToFahrenheit(celsius float64) float64 {
-	// TODO: Implement this function
-	// Remember to round to 2 decimal places
-	f := Round(celsius * 9.0 / 5.0 + 32.0, 2)
-	return f
+	return Round(celsius*9.0/5.0+32.0, 2)
 }

28-35: Remove TODO comments.

The function is correctly implemented with the proper formula and 2-decimal rounding. However, the TODO comments on lines 31-32 should be removed since the implementation is complete.

Optionally, you could simplify by returning directly:

 func FahrenheitToCelsius(fahrenheit float64) float64 {
-	// TODO: Implement this function
-	// Remember to round to 2 decimal places
-	c := Round((fahrenheit - 32) * 5.0 / 9.0, 2)
-	return c
+	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 231bd24 and 0874ace.

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

1-6: LGTM! Clean imports.

The package declaration and imports are appropriate. Both fmt and math are utilized in the implementation.


8-17: LGTM! Clear example usage.

The main function provides clear examples of both temperature conversion directions with appropriate formatting.


37-41: LGTM! Correct rounding implementation.

The Round helper function uses a standard and correct approach for rounding floats to a specified number of decimal places. It works well for the use case in this challenge (rounding to 2 decimals).

@RezaSi RezaSi merged commit 3ff4a86 into RezaSi:main Nov 6, 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