Untitled

mail@pastecode.io avatar
unknown
golang
a year ago
459 B
2
Indexable
Never
func isReachableAtTime(sx int, sy int, fx int, fy int, t int) bool {
    // Min step possible would be whatever is larger from modulus of x difference or y difference
    
    xDiff := math.Abs(float64(sx-fx))
    yDiff := math.Abs(float64(sy-fy))
    
    minStepsrequired := int(math.Max(xDiff, yDiff))
    
    if xDiff == 0 && yDiff == 0 {
        if t == 1 {
            return false
        }
    }
    
    return minStepsrequired <= t
}