Implement the sliding/merging function for the 2048 game. Given a row (or board) of integer tiles, simulate a swipe in a given direction: tiles slide toward the swipe direction, adjacent equal tiles merge into one tile with doubled value (each tile can only participate in one merge per swipe), and…