From c5c62a0aebb5ea714133c26e1f204cf85f07cb48 Mon Sep 17 00:00:00 2001 From: "exercism-solutions-syncer[bot]" <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 10 Apr 2026 14:35:15 +0000 Subject: [PATCH] [Sync Iteration] go/vehicle-purchase/1 --- .../go/vehicle-purchase/1/vehicle_purchase.go | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 solutions/go/vehicle-purchase/1/vehicle_purchase.go diff --git a/solutions/go/vehicle-purchase/1/vehicle_purchase.go b/solutions/go/vehicle-purchase/1/vehicle_purchase.go new file mode 100644 index 0000000..17a384d --- /dev/null +++ b/solutions/go/vehicle-purchase/1/vehicle_purchase.go @@ -0,0 +1,28 @@ +package purchase + +// NeedsLicense determines whether a license is needed to drive a type of vehicle. Only "car" and "truck" require a license. +func NeedsLicense(kind string) bool { + return kind == "car" || kind =="truck" +} + + +// ChooseVehicle recommends a vehicle for selection. It always recommends the vehicle that comes first in lexicographical order. +func ChooseVehicle(option1, option2 string) string { + if option1 < option2 { + return option1 + " is clearly the better choice." + } + return option2 + " is clearly the better choice." +} + +// CalculateResellPrice calculates how much a vehicle can resell for at a certain age. +func CalculateResellPrice(originalPrice, age float64) float64 { + var price float64 + if age < 3 { + price = originalPrice * 0.8 + } else if age >= 10 { + price = originalPrice * 0.5 + } else { + price = originalPrice * 0.7 + } + return price +}