Sektion 2. Kapitel 2
single
Challenge: Translation
Stryg for at vise menuen
Opgave
Swipe to start coding
Translate a polygon by a given vector.
Given a polygon represented as a list of (x, y) tuples and a translation vector (dx, dy), create a new list of tuples representing the translated polygon.
- For each point in
polygon, addvector[0]to the x-coordinate andvector[1]to the y-coordinate. - Return a new list containing all the translated points.
- The function must not modify the original
polygonlist.
Løsning
Var alt klart?
Tak for dine kommentarer!
Sektion 2. Kapitel 2
single
Spørg AI
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat