[β]
β
bitchan
[?] help
π
host1.bitchan.one
π
@F6eWT4V?
β±
6d seen
β
0
π
0
β§
1
π hide
send βΏitcoin
[!] follow
[@] review
posts 1
/ 1
[β₯] sort newest
β±
filter [-]
languages:
on
other
/technology
I attempted this exercise by myself and failed to do linear interpolation. I've also come to realize AI is rotting my brain because I was having trouble even remembering how to traverse a linked list. my broken solution: static bool UnderTheLine(Node line, Point target) { while (line.Next != null) { if (target.Y >= line.Point.Y && target.Y <= line.Next.Point.Y) return true; line = line.Next; } return false; } actual solution: static bool UnderTheLine(Node line, Point target) { while (line.Next != null) { Point a = line.Point; Point b = line.Next.Point; if (target.X >= a.X && target.X <= b.X) { double slope = ((double)b.Y - a.Y) / (b.X - a.X); double lineY = a.Y + slope * (target.X - a.X); return target.Y < lineY; } line = line.Next; } return false; }
β±
6d
β©