3 ms·
I spent like 10 hours working on this: https://news.ycombinator.com/item?id=11452445 https://news.ycombinator.com/item?id=11452445 and I thought I nailed it. Un
by hiphipjorge 11y ago
I spent like 10 hours working on this: https://news.ycombinator.com/item?id=11452445 https://news.ycombinator.com/item?id=11452445 and I thought I nailed it. Unfortunately, they passed and never told me what was wrong with it. To this day I'm still curious what the problem was!
Anyone here from FB who passed this and knows what I did wrong?
- hiphipjorge 11y agoWrong link: https://github.com/thejsj/calendar-exercise https://github.com/thejsj/calendar-exercise
- donatj 11y agoThat is the EXACT same problem they had me work on! We should start a club. I tried to impress them by not using any libraries, that may have been a mistake. It was a couple years ago now...
- vector57 11y agoI am not from Facebook, but I read through your tests and found one that violates the problem description on line 74 of test/index.js. The first statement of the problem is, "If two events collide in time, they MUST have the same width." So a width of 2/3 is not possible, all widths must have a numerator of 1. This rule is important because it makes the widths of the events deterministic, which otherwise they are not. That same test illustrates this exact problem, why not have the widths be 1/2, 1/4, 1/4, 1/2? Considering the first constraint the correct layout is all having width 1/3. https://github.com/thejsj/calendar-exercise/blob/master/test/index.js#L74 https://github.com/thejsj/calendar-exercise/blob/master/test...
- spion 11y agoThe solution violated the invariant: > If two events collide in time, they MUST have the same width. This is an invariant. Call this width W The solution is actually much easier that way.