Skip to content

Conversation

@Sairaviteja27
Copy link
Contributor

Challenge 18 Solution

Submitted by: @Sairaviteja27
Challenge: Challenge 18

Description

This PR contains my solution for Challenge 18.

Changes

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

Walkthrough

Introduces a new Go solution file for challenge-18 that implements temperature conversion utilities. The file contains functions to convert between Celsius and Fahrenheit, along with a rounding helper to ensure two-decimal precision, and includes example usage in main.

Changes

Cohort / File(s) Summary
Temperature Conversion Solution
challenge-18/submissions/Sairaviteja27/solution-template.go
New file with three exported functions: CelsiusToFahrenheit() and FahrenheitToCelsius() for bidirectional temperature conversion, and Round() helper to enforce two-decimal precision. Includes demonstration code in main().

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • Add solution for Challenge 18 by Be1chenok #578 — Adds identical temperature conversion functions (CelsiusToFahrenheit, FahrenheitToCelsius) and the same Round helper with equivalent implementations to another challenge-18 submission file.

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 PR title "Add solution for Challenge 18 by Sairaviteja27" directly describes the main change in the changeset. The title clearly and accurately summarizes what was added—a solution submission for Challenge 18 from a specific user. The title is concise and specific enough to convey the primary change without being vague or misleading, even though it doesn't include implementation details (which is not required per the guidelines).
Description Check ✅ Passed The PR description is clearly related to the changeset. It identifies the challenge being solved, specifies the exact file being added at challenge-18/submissions/Sairaviteja27/solution-template.go, and confirms that testing was completed and Go best practices were followed. While the description doesn't detail the specific implementation (temperature conversion functions), it provides sufficient context and is directly on-topic, meeting the lenient pass criterion that the description 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: 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 12f287c and c619108.

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

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

The example usage effectively demonstrates both temperature conversions with appropriate formatting.


37-41: LGTM! Standard and correct rounding implementation.

The Round function correctly implements decimal place rounding using the precision multiplier pattern.

Comment on lines +22 to +25
// TODO: Implement this function
// Remember to round to 2 decimal places
fah := Round(celsius * 9/5 + 32, 2)
return fah
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 TODO comments and consider simplifying the return.

The function is already implemented, so the TODO comments should be removed. Additionally, the intermediate variable can be eliminated for cleaner code.

Apply this diff to remove TODOs and simplify:

-	// TODO: Implement this function
-	// Remember to round to 2 decimal places
-	fah := Round(celsius * 9/5 + 32, 2)
-	return fah
+	return Round(celsius*9.0/5.0+32, 2)

Note: Using 9.0/5.0 makes it explicit that floating-point division is intended, though 9/5 works correctly here due to type conversion.

📝 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
fah := Round(celsius * 9/5 + 32, 2)
return fah
return Round(celsius*9.0/5.0+32, 2)
🤖 Prompt for AI Agents
In challenge-18/submissions/Sairaviteja27/solution-template.go around lines 22
to 25, remove the leftover TODO comments and simplify the function by returning
the rounded Fahrenheit directly instead of assigning to an intermediate
variable; replace the two-line implementation with a single return of
Round(celsius*9.0/5.0+32, 2) (using 9.0/5.0 to make floating-point division
explicit).

Comment on lines +31 to +34
// TODO: Implement this function
// Remember to round to 2 decimal places
cel := Round((fahrenheit - 32) * 5/9, 2)
return cel
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 TODO comments and consider simplifying the return.

Similar to CelsiusToFahrenheit, the TODO comments should be removed and the code can be simplified.

Apply this diff:

-	// TODO: Implement this function
-	// Remember to round to 2 decimal places
-	cel := Round((fahrenheit - 32) * 5/9, 2)
-	return cel
+	return Round((fahrenheit-32)*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
cel := Round((fahrenheit - 32) * 5/9, 2)
return cel
return Round((fahrenheit-32)*5.0/9.0, 2)
🤖 Prompt for AI Agents
In challenge-18/submissions/Sairaviteja27/solution-template.go around lines 31
to 34, remove the TODO comment and simplify the function by returning the
rounded value directly; replace the temporary variable assignment with a single
return that calls Round((fahrenheit - 32) * 5.0/9.0, 2) (ensure float literals
for division) and remove any leftover TODO text.

@RezaSi RezaSi merged commit 537c80d into RezaSi:main Oct 20, 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