Skip to content

Latest commit

 

History

History
7 lines (5 loc) · 444 Bytes

File metadata and controls

7 lines (5 loc) · 444 Bytes

Given a list of integers of length 5, for every 2 in the list, add the number 5 in front of it, and for every 5 in the list, add the number 2 in front of it. If there are no 2s or 5s, return the original list.

For example:

  • preceding_number25([1, 2, 3, 4, 5]) → [1, 5, 2, 3, 4, 2, 5]
  • preceding_number25([2, 2, 2, 2, 2]) → [5, 2, 5, 2, 5, 2, 5, 2, 5, 2]
  • preceding_number25([4, 8, 15, 16, 23]) → [4, 8, 15, 16, 23]