Git Product home page Git Product logo

scheduling's People

Contributors

kneerunjun avatar

Stargazers

 avatar

Watchers

 avatar  avatar

scheduling's Issues

Co incidence and conflict - need to resolve

See the code documentation here

This section in the code needs a slight change in the conditional check. Coincidental schedules cannot be regarded as conflicting. Yes we may have to make changes to implementation of 2 schedules as well

scheduling/sched.go

Lines 137 to 161 in 5de802a

func overlapsWith(left, right Schedule) (bool, bool, bool) {
var outside, inside, overlap bool
// Midpoints are distance of the half time since midnight for any schedule
mdpt1, mdpt2 := left.Midpoint(), right.Midpoint()
// half duration of each schedule
hfdur1, hfdur2 := left.Duration()/2, right.Duration()/2
// getting the absolute of the midpoint distance
mdptdis := mdpt1 - mdpt2
if mdptdis < 0 {
mdptdis = -mdptdis
}
// Getting the larger of the 2 schedules
var min, max int
if hfdur1 <= hfdur2 {
min, max = hfdur1, hfdur2
} else {
min, max = hfdur2, hfdur1
}
if outside, inside = (mdptdis > (hfdur1 + hfdur2)), ((mdptdis + min) < max); outside || inside {
overlap = false
} else {
overlap = true
}
return outside, inside, overlap
}

`overlapsWith()` test

Have changed the function to return 3 different values, check the working of the same using various end cases.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.