JuliaPluto / featured

https://featured.plutojl.org
12 stars 9 forks source link

Add Optimal Meatballs and The Traveling Salesman Game #53

Closed mthelm85 closed 8 months ago

mthelm85 commented 8 months ago

Hi Fons - I added another notebook, in addition to the optimal meatballs notebook I submitted last week. I deleted my previous fork of the repo without knowing that would cause my previous pull request to be deleted, so this request now has 2 notebooks included: Optimal Meatballs and The Traveling Salesman Game (which incorporates a Phaser.js game into the notebook!).

fonsp commented 8 months ago

Original PR - https://github.com/JuliaPluto/featured/pull/49

fonsp commented 8 months ago

Hey @mthelm85, sorry for the late reply!!

The traveling salesman notebook is super cool!! Very fun to see JS and Julia combined 💛

Do you think you could add some small comments to the code in the bottom? You don't have to explain how everything works, but just add some labels. Like

function random_point(bounds, points)
    x = rand(bounds.x:bounds.x + bounds.width - 1)
    y = rand(bounds.y:bounds.y + bounds.height - 1)

    threshold = 20
    for point in points
        if abs(point.x - x) < threshold || abs(point.y - y) < threshold
            return random_point(bounds, points)
        end
    end

    return Point(x, y)
end;

It would be nice to add a comment to explain what the code in the middle is for.

Thanks again!!

fonsp commented 8 months ago

The meatballs notebook looks good!!

mthelm85 commented 8 months ago

Hey @mthelm85, sorry for the late reply!!

The traveling salesman notebook is super cool!! Very fun to see JS and Julia combined 💛

Do you think you could add some small comments to the code in the bottom? You don't have to explain how everything works, but just add some labels. Like

function random_point(bounds, points)
    x = rand(bounds.x:bounds.x + bounds.width - 1)
    y = rand(bounds.y:bounds.y + bounds.height - 1)

    threshold = 20
    for point in points
        if abs(point.x - x) < threshold || abs(point.y - y) < threshold
            return random_point(bounds, points)
        end
    end

    return Point(x, y)
end;

It would be nice to add a comment to explain what the code in the middle is for.

Thanks again!!

Of course! I added several comments to try to explain more of the code. I'm happy to add more if you think it would be helpful.