6
It's really frustrating when I'm working and I have a ton of windows open that are completely or partially hidden behind other windows. To make things worse, I'm still using two 1024x768 monitors.
Your task is to take a list of coordinates that designate the area, in pixels, on a screen, that a list of windows occupy and output a truthy value if, for a 2 monitor set-up with 1024x768 resolution, all the following conditions are met:
- None of the windows would overlap,
- None of the windows would be partly off screen
- None of the windows would straddle a boundary between the two monitors (so the order in which you visualize monitors 1 and 2 is irrelevant)
And a falsey value if any of these criteria are not met.
You may assume that all windows are rectangular, and that no coordinates are negative in the input, which is in a file, in stdin, or in a list of tuples, is in the following format:
monitor-number left-x bottom-y right-x top-y
monitor-number left-x bottom-y right-x top-y
monitor-number left-x bottom-y right-x top-y
Where each line contains the ID of the monitor (which can either be in [1, 2]
or [0, 1]
depending on which is easier for your language), and the dimensions of a window.
For example, the following input will result in a truthy output because none of the windows overlap:
1 10 10 100 200
1 210 300 600 600
2 10 10 100 200
The following input will result in a falsey value because lines 1 and 3 result in an overlap:
1 10 10 50 50
2 5 5 600 200
1 20 20 80 80
The following input will result in a falsey value because it would partially off-screen on one of the monitors:
1 1000 400 1400 300
This is code-golf so the shortest solution wins.
Can I also take input as a list of tuples which is passed to my function? – ThreeFx – 2017-06-18T20:39:03.593
@ThreeFx sure, let me update my post. – Govind Parmar – 2017-06-18T20:39:20.903
I suppose we are assuming that the monitor with minimum ID has its right edge aligned exactly with the left edge of the other? (My 1 and 2 are in fact the other way around :)) – Jonathan Allan – 2017-06-18T21:38:57.153
@JonathanAllan Sure, but either way, the criteria for truthy output is that it can't partially be on either monitor – Govind Parmar – 2017-06-18T21:39:31.987
wait - if they straddle that should yield a falsey value, even if they are not off screen? – Jonathan Allan – 2017-06-18T21:41:54.843
@JonathanAllan Yes, but reading my OP again I didn't make that as explicitly clear as I should have. I'll edit my post again. – Govind Parmar – 2017-06-18T21:42:39.807
I think that could do with a test case or two too. – Jonathan Allan – 2017-06-18T21:43:18.757
@JonathanAllan The final example I include would fail because it straddles the 1024x768 boundary of monitor 1, even if monitor 2 is directly to its right – Govind Parmar – 2017-06-18T21:46:36.443
I have assumed
0
s are off screen, is that correct? – Jonathan Allan – 2017-06-18T22:59:29.587@JonathanAllan Since I forgot to address that when asking the question, let's say it's permissible to include or exclude 0 as a valid coordinate – Govind Parmar – 2017-06-19T00:35:51.610