3 ms·
I have a completely absurd way to use python to approximate the integer solution. Right answer achieved via hopes and prayers: from PIL import Image f
by mk_stjames 3y ago
I have a completely absurd way to use python to approximate the integer solution. Right answer achieved via hopes and prayers:
from PIL import Image
from math import ceil
given=3
def is_orange(p):
return 200 <= p[0] <= 255 and 100 <= p[1] <= 170 and 0 <= p[2] <= 50
img = Image.open("p9-problem.png")
w, h = img.size
o = (sum(is_orange(img.getpixel((w // 2, y))) for y in range(h)))
T = (sum(p[:3] != (p[0], p[0], p[0]) for p in (img.getpixel((w // 2, i)) for i in range(h))))
L = ceil((T/o)*given)
print(L**2)
Think about how many ways this could be tricked.... :)
- deleted 3y ago[deleted]
- somat 3y agoFor one it is making the rather large assumption that the image is to dimension.
- mk_stjames 3y agoYes, and it doesn't seem to be (there is no way the side is 12 if that given is 3, looks more like ~9). So yeah... complete luck was had here.
- nerdponx 3y agoIt looks deliberately not to dimension. In the process of getting to the answer I figured out that the width of the yellow rectangle is actually twice the width of the green and pink rectangles. It's a fakeout because it is correct that the green and pink rectangles have the same height.