package main

// tenths is the chance that the next trial is a yes, in tenths of a percent:
// 1000*(s+1)/(t+2) rounded half up by integer arithmetic, then clamped to
// 1..999 so the display never reads 0.0% or 100.0%. The exact fraction is
// never 0 or 1; the clamp only repairs rounding on very long runs.
func tenths(s, t int) int {
	p := (2000*(s+1) + (t + 2)) / (2 * (t + 2))
	return min(max(p, 1), 999)
}

// toNinety is the number of further consecutive yeses after which
// (s+k+1)/(t+k+2) >= 0.9, from 10(s+k+1) >= 9(t+k+2).
func toNinety(s, t int) int {
	return max(9*t-10*s+8, 0)
}
