Skip to content

Instantly share code, notes, and snippets.

@filipearray
Last active May 11, 2024 02:05
Show Gist options
  • Save filipearray/e7e566db4dd42e93f82df4d26d1b84c1 to your computer and use it in GitHub Desktop.
Save filipearray/e7e566db4dd42e93f82df4d26d1b84c1 to your computer and use it in GitHub Desktop.
Cars Assemble
package cars
// CalculateWorkingCarsPerHour calculates how many working cars are
// produced by the assembly line every hour.
func CalculateWorkingCarsPerHour(productionRate int, successRate float64) float64 {
var onePercentProductionRate float64 = float64(productionRate) / 100
var workingCarsPerHour float64 = onePercentProductionRate * successRate
return workingCarsPerHour
panic("CalculateWorkingCarsPerHour not implemented")
}
// CalculateWorkingCarsPerMinute calculates how many working cars are
// produced by the assembly line every minute.
func CalculateWorkingCarsPerMinute(productionRate int, successRate float64) int {
var producedCarsPerHour float64 = CalculateWorkingCarsPerHour(productionRate, successRate)
var producedCarsPerMinute int = int(producedCarsPerHour / 60)
return producedCarsPerMinute
panic("CalculateWorkingCarsPerMinute not implemented")
}
// CalculateCost works out the cost of producing the given number of cars.
func CalculateCost(carsCount int) uint {
remainder := carsCount % 10
setOfTen := carsCount / 10
plannedCost := setOfTen * 95000
individualCost := remainder * 10000
totalCost := plannedCost + individualCost
return uint(totalCost)
panic("CalculateCost not implemented")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment