Hacker News new | past | comments | ask | show | jobs | submit login

That's half of it, but doesn't account for the case when starttime[1] is later than endtime[2] and they don't intersect.



It works if you assume that appointment 1 starts before appointment 2 starts (or if you explicitly sort them by start time).

e.g. in J:

       'a b c' =: 50 60 3 4;3 50 49 99;2 10 10 12  NB. 3 different sets of appointments
       3 :'ok`nope{~0>*./-~//./:~_2]\ y' every a;b;c
    ┌──┬────┬──┐
    │ok│nope│ok│
    └──┴────┴──┘


Good point. I didn't think about them not being written down in the list in chronological order by start time.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: