algorithm-archive
algorithm-archive copied to clipboard
Update Julia Jarvis March to use points from Graham Scan
This uses the points from https://github.com/algorithm-archivists/algorithm-archive/blob/4313e7eb3d2faa152590c631d180d06a5c85f46d/contents/graham_scan/code/julia/graham.jl#L50
It revealed a bug in this implementation that needs to be fixed.
Could you elaborate on the bug a bit?
Sure. The output from the Python code is
(-14, -14)
(15, -9)
(9, 9)
(0, 14)
(-6, 15)
(-10, 11)
but, from the same initial points, the Julia output is
Pos[Pos(-14.0, -14.0), Pos(15.0, -9.0), Pos(-6.0, 15.0), Pos(-14.0, -14.0)]
I haven't bothered to debug this. If someone sees the obvious fix, feel free to modify this PR or issue a new one.
So I was looking at this today. There is definitely a bug in some implementations, but it is unclear what that is because the python code is radically different. We can rewrite the julia code to match the python code, but right now we probably need a better way of defining all the points to find the convex hull.
I really need to revise these chapters anyway, so I'll bump that up on the list.
I feel like we had this discussion somewhere on github before, but I can't find it. Sorry!
The discussion was in https://github.com/algorithm-archivists/algorithm-archive/pull/708#issuecomment-633322788. What solution do you think is better, that one, or this hard-coded set? The points inside or on a circle from a square grid makes more sense to me.
I agree. The only caveat is that we need to somehow ensure all output is the same. A hard-coded set is easier to do that with.
Yes, also my thoughts. Well, we are already going on a system of trust with PR review. One thing that might help is sorting the output. Ideally the output is also not big, which is easily checked.
[lang: julia]