Skip to content

Conversation

@AlexO-85
Copy link
Contributor

@AlexO-85 AlexO-85 commented Nov 6, 2025

Challenge 18 Solution

Submitted by: @AlexO-85
Challenge: Challenge 18

Description

This PR contains my solution for Challenge 18.

Changes

  • Added solution file to challenge-18/submissions/AlexO-85/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 6, 2025

Walkthrough

Introduces a new Go program with temperature conversion utilities. Implements CelsiusToFahrenheit and FahrenheitToCelsius functions that perform bidirectional temperature conversions and return results rounded to two decimal places. Includes a Round helper function for consistent decimal precision across conversions.

Changes

Cohort / File(s) Summary
Temperature conversion functions
challenge-18/submissions/AlexO-85/solution-template.go
New file adding CelsiusToFahrenheit, FahrenheitToCelsius conversion functions using standard formulas (F = C × 9/5 + 32 and C = (F − 32) × 5/9), plus Round utility function for 2-decimal rounding; includes main function with example usage.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Three straightforward utility functions with basic arithmetic operations
  • No complex control flow, error handling, or conditional logic
  • Rounding implementation using standard math.Round approach
  • Homogeneous pattern: two similar conversion functions following identical structure

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 accurately reflects the main change: adding a solution for Challenge 18 by the specified author to the repository.
Description check ✅ Passed The description is directly related to the changeset, providing context about the Challenge 18 solution submission and the file location.

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: 3

🧹 Nitpick comments (1)
challenge-18/submissions/AlexO-85/solution-template.go (1)

36-39: Consider validating the decimals parameter.

The Round function doesn't validate that decimals is non-negative. While negative values would technically work with math.Pow10, they might produce unexpected behavior. Consider adding a check if this function will be used more broadly.

Example validation:

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 1a06951 and 37d15a2.

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

1-6: LGTM!

Package declaration and imports are appropriate for the temperature conversion utilities.


8-17: LGTM!

The example usage clearly demonstrates both conversion functions with well-formatted output.

Comment on lines +22 to +23
// TODO: Implement this function
// Remember to round to 2 decimal places
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Remove leftover TODO comments.

The function is already implemented correctly, so these TODO comments from the template should be removed.

Apply this diff:

-	// TODO: Implement this function
-	// Remember to round to 2 decimal places
 	return Round(celsius*9.0/5.0 + 32.0, 2)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// TODO: Implement this function
// Remember to round to 2 decimal places
return Round(celsius*9.0/5.0 + 32.0, 2)
🤖 Prompt for AI Agents
In challenge-18/submissions/AlexO-85/solution-template.go around lines 22 to 23,
remove the leftover TODO comment lines ("// TODO: Implement this function" and
"// Remember to round to 2 decimal places") since the function is already
implemented; simply delete those two comment lines to clean up the file.

Comment on lines +30 to +31
// TODO: Implement this function
// Remember to round to 2 decimal places
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Remove leftover TODO comments.

The function is already implemented correctly, so these TODO comments from the template should be removed.

Apply this diff:

-	// TODO: Implement this function
-	// Remember to round to 2 decimal places
 	return Round((fahrenheit - 32.0) * 5.0 / 9.0, 2)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// TODO: Implement this function
// Remember to round to 2 decimal places
return Round((fahrenheit - 32.0) * 5.0 / 9.0, 2)
🤖 Prompt for AI Agents
In challenge-18/submissions/AlexO-85/solution-template.go around lines 30 to 31,
remove the leftover TODO comment lines ("// TODO: Implement this function" and
"// Remember to round to 2 decimal places") because the function is already
implemented; simply delete those two comment lines so the file no longer
contains stale template TODOs.

Comment on lines +35 to +36
// Round rounds a float64 value to the specified number of decimal places
func Round(value float64, decimals int) float64 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add documentation comment for exported function.

Go best practices require documentation comments for all exported identifiers. The Round function needs a documentation comment explaining its purpose and parameters.

Apply this diff:

-// Round rounds a float64 value to the specified number of decimal places
+// Round rounds a float64 value to the specified number of decimal places.
+// For example, Round(3.14159, 2) returns 3.14.
 func Round(value float64, decimals int) float64 {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Round rounds a float64 value to the specified number of decimal places
func Round(value float64, decimals int) float64 {
// Round rounds a float64 value to the specified number of decimal places.
// For example, Round(3.14159, 2) returns 3.14.
func Round(value float64, decimals int) float64 {
🤖 Prompt for AI Agents
In challenge-18/submissions/AlexO-85/solution-template.go around lines 35 to 36,
the exported Round function lacks a Go documentation comment; add a doc comment
immediately above the function starting with "Round" that briefly describes what
the function does, its parameters (value float64, decimals int) and what it
returns (rounded float64), e.g. one or two concise sentences following Go doc
conventions.

@RezaSi RezaSi merged commit 2bcffbe 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