Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions challenge-18/submissions/AlexO-85/solution-template.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package main

import (
"fmt"
"math"
)

func main() {
// Example usage
celsius := 25.0
fahrenheit := CelsiusToFahrenheit(celsius)
fmt.Printf("%.2f°C is equal to %.2f°F\n", celsius, fahrenheit)

fahrenheit = 68.0
celsius = FahrenheitToCelsius(fahrenheit)
fmt.Printf("%.2f°F is equal to %.2f°C\n", fahrenheit, celsius)
}

// 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
Comment on lines +22 to +23
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.

return Round(celsius*9.0/5.0 + 32.0, 2)
}

// 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
Comment on lines +30 to +31
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.

return Round((fahrenheit - 32.0) * 5.0 / 9.0, 2)
}

// Round rounds a float64 value to the specified number of decimal places
func Round(value float64, decimals int) float64 {
Comment on lines +35 to +36
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.

precision := math.Pow10(decimals)
return math.Round(value*precision) / precision
}
Loading