Your task is to write a program or function which, given two nonzero integers
y, returns a truthy value if the image at coordinates
x east and
y north of xkcd's click and drag comic is mostly white and a falsey value otherwise.
- The image should be retrieved from imgs.xkcd.com/clickdrag/[y]n[x]e.png, where
[x]are replaced with the absolute values of the input
eshould be changed to a
nshould be changed to a
- If a 404 error is returned, assume the image is mostly white (output truthy) if
yis positive and mostly black otherwise. This is because (as far as I can tell) xkcd stores neither completely white regions of the sky nor completely black regions of the ground, leading to less data in their servers and these 404s you must handle. This error handling is not intended to deal with the images not being available.
- "white" is defined as rgb #FFFFFF. You may assume that the images are only white(#FFFFFF) and black(#000000), without gray or other colors. "Mostly white" is defined as at least 2097153 pixels of the image are white (because the png the program should retrieve from img.xkcd.com is always 2048x2048 pixels).
- The program may have any behavior when dealing with pixels that are not exactly #FFFFFF nor #000000 but must produce the same output as expected for the test cases.
The image at
y=9 should be retrieved from
imgs.xkcd.com/clickdrag/9n2e.png and appears as follows (formatted as quote to show border):
It is mostly white, so the program should return a truthy value.
Input / Output
Input should be two integers or a list of two integers representing
Output should be a truthy or falsy value corresponding to if the image is mostly white.
Input and output should be through any standard I/O method.
Truthy (as (x,y))
2,9 7,-17 9, 5 3, 2 -5, 1 1, 3
Falsy (as (x,y))
3, 1 3, -1 7, -16 2, 1 5, 1 17, -1