Untitled

mail@pastecode.io avatar
unknown
plain_text
5 months ago
322 B
3
Indexable
func TryFinish(car *Car, distance int) string {
	approximate_distance := distance

	if distance%2 != 0 {
		approximate_distance -= 1
	}

	if car.battery*2 < approximate_distance {
		car.battery = 0
		return ""
	} else {
		car.battery -= distance / 2
		return fmt.Sprintf("%.2f", float64(distance)/float64(car.speed))
	}

}
Leave a Comment