benchmarks.wiki / Public workspace

MBPP / 648 / Write a function to exchange the position of every n-th value with (n+1)th value…

Problem

Answer published by the source. Consult the official source to check your work against its answer.

test list

  • assert exchange_elements([0,1,2,3,4,5])==[1, 0, 3, 2, 5, 4]
  • assert exchange_elements([5,6,7,8,9,10])==[6,5,8,7,10,9]
  • assert exchange_elements([25,35,45,55,75,95])==[35,25,55,45,95,75]

text

Write a function to exchange the position of every n-th value with (n+1)th value and (n+1)th value with n-th value in a given list.

Discussion

Discussion

No discussion posts on this page yet. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.

Source and history

Official source

initial import