From 14dafe03363ef3e64c717ec3707e291e32749c30 Mon Sep 17 00:00:00 2001 From: "exercism-solutions-syncer[bot]" <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Wed, 8 Oct 2025 12:13:14 +0000 Subject: [PATCH] [Sync Iteration] go/cars-assemble/1 --- solutions/go/cars-assemble/1/cars_assemble.go | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 solutions/go/cars-assemble/1/cars_assemble.go diff --git a/solutions/go/cars-assemble/1/cars_assemble.go b/solutions/go/cars-assemble/1/cars_assemble.go new file mode 100644 index 0000000..b59f1a0 --- /dev/null +++ b/solutions/go/cars-assemble/1/cars_assemble.go @@ -0,0 +1,24 @@ +package cars + +// CalculateWorkingCarsPerHour calculates how many working cars are +// produced by the assembly line every hour. +func CalculateWorkingCarsPerHour(productionRate int, successRate float64) float64 { + return float64(productionRate) * (successRate / 100) +} + +// CalculateWorkingCarsPerMinute calculates how many working cars are +// produced by the assembly line every minute. +func CalculateWorkingCarsPerMinute(productionRate int, successRate float64) int { + return int(CalculateWorkingCarsPerHour(productionRate, successRate) / 60) +} + +// CalculateCost works out the cost of producing the given number of cars. +func CalculateCost(carsCount int) uint { + normalCost := 10000 + discountCost := 95000 + + var restOfCar int = carsCount % 10 + var discountCars int = (carsCount - restOfCar) / 10 + + return uint((discountCars * discountCost) + (restOfCar * normalCost)) +}