#Day 09 Discussion
166 messages · Page 1 of 1 (latest)
except that p2 might be the hardest part of the entire year
Not sure how to do part 2
I got the brute force solution but it just takes to long lmfao
I can't even see a brute force way 
I think there must be some geometry formular with which you can solve p2 trivially
happened in the past
i tried marking all points that can be inside the enclosed shaped and its just too many points
it's over
ok i think i have somethign
bro u doing day 9 or?
yes I did d9p1 and now groking p2 which I guess just means there is an inside shape
yes it means trying to understand - not the musk abomination/appropriation
so it's just a ||polygon and they give us the order even|| (should I spoiler this)
very hard
definitely not an optimal solution but whatever
yeah lmao i reused code
||it's the same approach but you use a max heap instead of a min heap with a different cost function||
you should probably spoil this tbh
it's not a spoiler
I feel so stupid for not looking at the input closely
I just noticed that now lol
it's there in the image
damn I'm sdumb af
wait why do I remember the math tech for this
unlocked sophomore year wisdom hold on
||Couldn't it also be concave?||
||well I was wondering concave/convex yes|| but I don't know if it matters yet
||still a polygon, some parts of it do seem to be concave tho||
It does matter tho for the checks....
It works for the example but not for the actual input 
hmm Width: 96850 Height: 96672
that's ... a bit much
I thought I'd be cool and draw the input
Okay i gotta work, someone ping me with a hint after you get it
work at midnight twf bro
||What I mean is like this
@#@ @#@
### ###
##@###@##
#########
@#######@
So now if you just check if the corners are all inside the red/green area it will still give a bad output
||
It's 8:40 am
my drawing is better
u not late for work then?
LOL that's the exact example I showed to my friend
down to the concave direction
to show him how hard this problem is
I've been at work since 7:30
Just didn't work
rasterizer doesn't like it
panic: runtime error: slice bounds out of range [-2147442263:]
goroutine 1 [running]:
golang.org/x/image/vector.(*Rasterizer).floatingLineTo(0x102fc4618?, 0x2c80108?, 0x1?)
/Users/dl/go/pkg/mod/golang.org/x/[email protected]/vector/raster_floating.go:60 +0x3fc
golang.org/x/image/vector.(*Rasterizer).LineTo(0x102850060?, 0x2b37d0?, 0x140?)
/Users/dl/go/pkg/mod/golang.org/x/[email protected]/vector/vector.go:189 +0x24
grol.io/grol/extensions.createVectorImageFunctions.func2({0x102850060?, 0x140002b37d0?}, {0x1400002a178?, 0x102482e7c?}, {0x14000117140, 0x3, 0x1400002a1d8?})
/Users/dl/dev/grol-io/grol/extensions/images.go:470 +0xb4
looks like go doesn't like a slice (image) with 9,362,489,679 pixels
kinda weird it's using signed int32 instead of int64 (on a 64bit os)
||it's the death star||
||see the hole ...|| these bastards
just drew it at 1/10th scale
still don't know the algorithm tbh
wait
hmm
wait is this actually easy
i mayhaps have realised something
the algo is ||
for pt := points[1:] {
x := pt[0]
y := pt[1]
println("Line to:", x, y)
image.line_to(img, x, y)
}
```||
dimensions even after offset -minx,-miny are about 100k x 100k
10^5 * 10^5 = 10^10 yes
||draw all green points, start "flowing " from top to bottom. when you run into a red or green point, toggle the "interiority" flag on the tile. you can use this to compute interiority for all tiles but it's slow. you could alternatively mark each edge tile as an "off" or "on" tile||
based kek
green or red is a... wait for it... red herring
|| thats what i tried to do, its too many tiles to mark, memory suffers ||
will sleep on it, it's getting late here but this is fun
i think i'll just leave my brute force solution run over a few hours too
hopefully i get something
Ugh so many edge cases
My thinking:
|| Loop over all possible rectangles like in p1
Loop over each edge of the rectangle
Check if it intersects with any of the edges of the big polygon ||
but i can't get the math to work
ooo
|| thats what i am trying to do
generate all points that are on the edge or inside the enclosed polygon for all pairs of red tiles||
and its been at 100% 😢
i tried doing it all concurrently
checking of points
The input is ||ordered|| right?
so you can || calculate the edges || and || flood fill||?
it's a 10^5 x 10^5 grid
oww, only 10G xD
looking at my 32 GB of RAM
otherwise ||raycasting|| to check if a point is ||inside the polygon||
All points of the edge in a rectangle should be inside
||But then you have to check every point on the edge, not only the corners||
don't you have to do that anyways?
||You could check for intersections between every edge of the rectangle and every edge of the polygon, that should cover it, but couldn't get it to work||
ah right, that should work
i remember studying similar problem in my design and analysis of algorithms class (nearly 2 years ago) and i feel i could write equation and solve without making a giant grid in memory.
some modified version of ||convex hull|| would do the trick perhaps? and check if ||all corners of the rectangle with-in the area||.
The problem is that it's ||not convex :)||
someone made an alternative test input
1,0
3,0
3,6
16,6
16,0
18,0
18,9
13,9
13,7
6,7
6,9
1,9
.#X#............#X#.
.XXX............XXX.
.XXX............XXX.
.XXX............XXX.
.XXX............XXX.
.XXX............XXX.
.XX#XXXXXXXXXXXX#XX.
.XXXXX#XXXXXX#XXXXX.
.XXXXXX......XXXXXX.
.#XXXX#......#XXXX#.
answer: 30
I got an idea and then i looked at this and realized my idea is bad. ||thought i would check if all 4 corners of a rectangle is inside a some other rectangle||
My solution is not in Go but I am shocked nonetheless
day09_part2 time: [1.8604 ms 1.9990 ms 2.1471 ms]
change: [−93.607% −93.303% −93.021%] (p = 0.00 < 0.05)
Performance has improved.
It's always a mf ||FixedBitSet|| and it's incredibly good at this
that panic I get looks buggy as slice index should be 64bits
ah probably because of https://cs.opensource.google/go/x/image/+/refs/tags/v0.34.0:vector/raster_fixed.go;l=27
bummer that discord doesn't take svg images
can't send svg so here is the... screenshot of the svg
This case isn't in the actual input for what it is worth. My solution doesn't support it
I ||only check || if || an edge intersects||
nobody give me any hints i hate getting hints. just was gonna say today is a mf
pretty sure i got the right idea but there's a bug somewhere
i feel like this should help me but i don't think it does lol
it’s mostly bitching how evil the aoc people are. apparently btw some people got a trapeze not a disc
yeah this one is nasty lol
I have a bug and it pisses me off - pretty close to throwing the towel 🙂
ditto lol i'm like 99% sure this is the correct (enough) appraoch but i got a bug too
yeah I might have to retry this one in go later on
(╯°□°)╯︵ ┻━┻
didn't turn on my pc at all yesterday, was doing some irls
I don't get it, I get "too high" for this:
that would imply it's a bad rectangle... but ... what's bad about it ?
@slate trench if I send you my input can you draw it? I wonder if they're all death stars
weird, I re ran it and...
sure, happy too! and I think there are 2 types: death stars and trapezes
same/similar:
leaderboard is borked btw it shows I did 10 which I haven't started
nvm that's my auto dark mode
after day 12 i'm gonna redo this one in go bc can't get part2 to work in elixir but i think i have right idea
if you send me your input I can draw it, curious if you also got a death star like @loud ridge and I
stole someone else's p2 solution, not a math guy and its 3 am and i was tired and stressed over other shit and just wanted to get done with this
i knew the basic gist of what i had to do but the final formula was a pain
im bout to but giving myself a few days.