Project Euler #228: Minkowski Sums

  • + 0 comments

    You can graph your results in wolfram alpha if you want a quick way to visualize your progress (only works for 10 vertices, so only good for basics)

    polygon with vertices [(2.00,0.00),(1.00,1.00),(-0.50,1.87),(-1.50,0.87),(-1.50,-0.87),(-0.50,-1.87),(1.00,-1.00)]

    displays as: https://www.wolframalpha.com/input/?i=polygon+with+vertices+%5B(2.00,0.00),(1.00,1.00),(-0.50,1.87),(-1.50,0.87),(-1.50,-0.87),(-0.50,-1.87),(1.00,-1.00)%5D

    Python pseudocode:

    link = 'https://www.wolframalpha.com/input/?i=polygon+with+vertices+'+str(vertices).replace(" ", "")
    

    where vertices are an array of objects that have:

        def __repr__(self):
            x = '{:6.2f}'.format(self.x)
            y = '{:6.2f}'.format(self.y)
            return "("+x+","+y+")"